ipa-inline-analysis.c (predicate_conditions): Move to ipa-inline.h (true_predicate...

* ipa-inline-analysis.c (predicate_conditions): Move to ipa-inline.h
	(true_predicate, false_predicate, true_predicate_p,
	false_predicate_p): Remove.
	(single_cond_predicate, not_inlined_predicate): Turn to member function
	in ipa-inline.h
	(add_condition): Update.
	(add_clause): Turn to...
	(predicate::add_clause): ... this one; update; allow passing NULL
	as parameter.
	(and_predicates): Turn to ...
	(predicate::operator &=): ... this one.
	(predicates_equal_p): Move to predicate::operator == in ipa-inline.h
	(or_predicates): Turn to ...
	(predicate::or_with): ... this one.
	(evaluate_predicate): Turn to ...
	(predicate::evaluate): ... this one.
	(predicate_probability): Turn to ...
	(predicate::probability): ... this one.
	(dump_condition): Update.
	(dump_predicate): Turn to ...
	(predicate::dump): ... this one.
	(account_size_time): Update.
	(edge_set_predicate): Update.
	(set_hint_predicate): UPdate.
	(evaluate_conditions_for_known_args): Update.
	(evaluate_properties_for_edge): Update.
	(remap_predicate_after_duplication): Turn to...
	(predicate::remap_after_duplication): ... this one.
	(remap_hint_predicate_after_duplication): Update.
	(inline_summary_t::duplicate): UPdate.
	(dump_inline_edge_summary): Update.
	(dump_inline_summary): Update.
	(set_cond_stmt_execution_predicate): Update.
	(set_switch_stmt_execution_predicate): Update.
	(compute_bb_predicates): Update.
	(will_be_nonconstant_expr_predicate): Update.
	(will_be_nonconstant_predicate): Update.
	(phi_result_unknown_predicate): Update.
	(predicate_for_phi_result): Update.
	(array_index_predicate): Update.
	(estimate_function_body_sizes): Update.
	(estimate_node_size_and_time): Update.
	(estimate_ipcp_clone_size_and_time): Update.
	(remap_predicate): Rename to ...
	(predicate::remap_after_inlining): ... this one.
	(remap_hint_predicate): Update.
	(inline_merge_summary): Update.
	(inline_update_overall_summary): Update.
	(estimate_size_after_inlining): Update.
	(read_predicate): Rename to ...
	(predicate::stream_in): ... this one.
	(read_inline_edge_summary): Update.
	(write_predicate): Rename to ...
	(predicate::stream_out): ... this one.
	(write_inline_edge_summary): Update.
	* ipa-inline.h (MAX_CLAUSES): Turn to predicate::max_clauses.
	(clause_t): Turn to uint32_t
	(predicate): Turn to class; implement constructor and operators
	==, !=, &
	(size_time_entry): Update.
	(inline_summary): Update.
	(inline_edge_summary): Update.

From-SVN: r248204
This commit is contained in:
Jan Hubicka 2017-05-18 16:18:08 +02:00 committed by Jan Hubicka
parent cdefeea2e6
commit dbcb3c7446
3 changed files with 627 additions and 558 deletions

View File

@ -1,3 +1,68 @@
2017-05-18 Jan Hubicka <hubicka@ucw.cz>
* ipa-inline-analysis.c (predicate_conditions): Move to ipa-inline.h
(true_predicate, false_predicate, true_predicate_p,
false_predicate_p): Remove.
(single_cond_predicate, not_inlined_predicate): Turn to member function
in ipa-inline.h
(add_condition): Update.
(add_clause): Turn to...
(predicate::add_clause): ... this one; update; allow passing NULL
as parameter.
(and_predicates): Turn to ...
(predicate::operator &=): ... this one.
(predicates_equal_p): Move to predicate::operator == in ipa-inline.h
(or_predicates): Turn to ...
(predicate::or_with): ... this one.
(evaluate_predicate): Turn to ...
(predicate::evaluate): ... this one.
(predicate_probability): Turn to ...
(predicate::probability): ... this one.
(dump_condition): Update.
(dump_predicate): Turn to ...
(predicate::dump): ... this one.
(account_size_time): Update.
(edge_set_predicate): Update.
(set_hint_predicate): UPdate.
(evaluate_conditions_for_known_args): Update.
(evaluate_properties_for_edge): Update.
(remap_predicate_after_duplication): Turn to...
(predicate::remap_after_duplication): ... this one.
(remap_hint_predicate_after_duplication): Update.
(inline_summary_t::duplicate): UPdate.
(dump_inline_edge_summary): Update.
(dump_inline_summary): Update.
(set_cond_stmt_execution_predicate): Update.
(set_switch_stmt_execution_predicate): Update.
(compute_bb_predicates): Update.
(will_be_nonconstant_expr_predicate): Update.
(will_be_nonconstant_predicate): Update.
(phi_result_unknown_predicate): Update.
(predicate_for_phi_result): Update.
(array_index_predicate): Update.
(estimate_function_body_sizes): Update.
(estimate_node_size_and_time): Update.
(estimate_ipcp_clone_size_and_time): Update.
(remap_predicate): Rename to ...
(predicate::remap_after_inlining): ... this one.
(remap_hint_predicate): Update.
(inline_merge_summary): Update.
(inline_update_overall_summary): Update.
(estimate_size_after_inlining): Update.
(read_predicate): Rename to ...
(predicate::stream_in): ... this one.
(read_inline_edge_summary): Update.
(write_predicate): Rename to ...
(predicate::stream_out): ... this one.
(write_inline_edge_summary): Update.
* ipa-inline.h (MAX_CLAUSES): Turn to predicate::max_clauses.
(clause_t): Turn to uint32_t
(predicate): Turn to class; implement constructor and operators
==, !=, &
(size_time_entry): Update.
(inline_summary): Update.
(inline_edge_summary): Update.
2017-05-18 Marc Glisse <marc.glisse@inria.fr>
* fold-const.c (fold_binary_loc): Move transformation...

File diff suppressed because it is too large Load Diff

View File

@ -80,23 +80,169 @@ enum inline_hints_vals {
};
typedef int inline_hints;
/* Information kept about parameter of call site. */
struct inline_param_summary
{
/* REG_BR_PROB_BASE based probability that parameter will change in between
two invocation of the calls.
I.e. loop invariant parameters
REG_BR_PROB_BASE/estimated_iterations and regular
parameters REG_BR_PROB_BASE.
Value 0 is reserved for compile time invariants. */
int change_prob;
};
typedef vec<condition, va_gc> *conditions;
/* Representation of predicates i.e. formulas using conditions defined
above. Predicates are simple logical formulas in conjunctive-disjunctive
form.
/* Predicates are used to repesent function parameters (such as runtime)
which depend on a context function is called in.
Predicate is array of clauses terminated by 0. Every clause must be true
in order to make predicate true.
Clauses are represented as bitmaps of conditions. One of conditions
must be true in order for clause to be true. */
Predicates are logical formulas in conjunctive-disjunctive form consisting
of clauses which are bitmaps specifying a set of condition that must
be true for a clause to be satisfied. Physically they are represented as
array of clauses terminated by 0.
#define MAX_CLAUSES 8
typedef unsigned int clause_t;
struct GTY(()) predicate
In order to make predicate (possibly) true, all of its clauses must
be (possibly) true. To make clause (possibly) true, one of conditions
it mentions must be (possibly) true.
There are fixed bounds on number of clauses and conditions and all the
manipulation functions are conservative in positive direction. I.e. we
may lose precision by thinking that predicate may be true even when it
is not. */
typedef uint32_t clause_t;
class predicate
{
clause_t clause[MAX_CLAUSES + 1];
public:
enum predicate_conditions
{
false_condition = 0,
not_inlined_condition = 1,
first_dynamic_condition = 2
};
/* Initialize predicate either to true of false depending on P. */
inline predicate (bool p = true)
{
if (p)
/* True predicate. */
m_clause[0] = 0;
else
/* False predicate. */
set_to_cond (false_condition);
}
/* Sanity check that we do not mix pointers to predicates with predicates. */
inline predicate (predicate *)
{
gcc_unreachable ();
}
/* Return predicate testing condition I. */
static inline predicate predicate_testing_cond (int i)
{
class predicate p;
p.set_to_cond (i + first_dynamic_condition);
return p;
}
/* Return predicate testing that function was not inlined. */
static predicate not_inlined (void)
{
class predicate p;
p.set_to_cond (not_inlined_condition);
return p;
}
/* Compute logical and of predicates. */
predicate & operator &= (const predicate &);
inline predicate operator &(const predicate &p)
{
predicate ret = *this;
ret &= p;
return ret;
}
/* Compute logical or of predicates. This is not operator because
extra parameter CONDITIONS is needed */
predicate or_with (conditions, const predicate &) const;
/* Return true if predicates are known to be equal. */
inline bool operator==(const predicate &p2) const
{
int i;
for (i = 0; m_clause[i]; i++)
{
gcc_checking_assert (i < max_clauses);
gcc_checking_assert (m_clause[i] > m_clause[i + 1]);
gcc_checking_assert (!p2.m_clause[i]
|| p2.m_clause[i] > p2.m_clause[i + 1]);
if (m_clause[i] != p2.m_clause[i])
return false;
}
return !p2.m_clause[i];
}
/* Return true if predicates are known to be true or false depending
on COND. */
inline bool operator==(const bool cond) const
{
if (cond)
return !m_clause[0];
if (m_clause[0] == (1 << false_condition))
{
gcc_checking_assert (!m_clause[1]
&& m_clause[0] == 1
<< false_condition);
return true;
}
return false;
}
inline bool operator!=(const predicate &p2) const
{
return !(*this == p2);
}
inline bool operator!=(const bool cond) const
{
return !(*this == cond);
}
/* Evaluate if predicate is known to be false given the clause of possible
truths. */
bool evaluate (clause_t) const;
/* Estimate probability that predicate will be true in a given context. */
int probability (conditions, clause_t, vec<inline_param_summary>) const;
/* Dump predicate to F. Output newline if nl. */
void dump (FILE *f, conditions, bool nl=true) const;
/* Return predicate equal to THIS after duplication. */
predicate remap_after_duplication (clause_t);
/* Return predicate equal to THIS after inlining. */
predicate remap_after_inlining (struct inline_summary *,
struct inline_summary *,
vec<int>, vec<int>, clause_t, const predicate &);
void stream_in (struct lto_input_block *);
void stream_out (struct output_block *);
private:
static const int max_clauses = 8;
clause_t m_clause[max_clauses + 1];
/* Initialize predicate to one testing single condition number COND. */
inline void set_to_cond (int cond)
{
m_clause[0] = 1 << cond;
m_clause[1] = 0;
}
void add_clause (conditions conditions, clause_t);
};
/* Represnetation of function body size and time depending on the inline
@ -108,11 +254,11 @@ struct GTY(()) predicate
struct GTY(()) size_time_entry
{
/* Predicate for code to be executed. */
struct predicate exec_predicate;
predicate exec_predicate;
/* Predicate for value to be constant and optimized out in a specialized copy.
When deciding on specialization this makes it possible to see how much
the executed code paths will simplify. */
struct predicate nonconst_predicate;
predicate nonconst_predicate;
int size;
sreal GTY((skip)) time;
};
@ -161,12 +307,12 @@ struct GTY(()) inline_summary
/* Predicate on when some loop in the function becomes to have known
bounds. */
struct predicate * GTY((skip)) loop_iterations;
predicate * GTY((skip)) loop_iterations;
/* Predicate on when some loop in the function becomes to have known
stride. */
struct predicate * GTY((skip)) loop_stride;
predicate * GTY((skip)) loop_stride;
/* Predicate on when some array indexes become constants. */
struct predicate * GTY((skip)) array_index;
predicate * GTY((skip)) array_index;
/* Estimated growth for inlining all copies of the function before start
of small functions inlining.
This value will get out of date as the callers are duplicated, but
@ -212,19 +358,6 @@ public:
extern GTY(()) function_summary <inline_summary *> *inline_summaries;
/* Information kept about parameter of call site. */
struct inline_param_summary
{
/* REG_BR_PROB_BASE based probability that parameter will change in between
two invocation of the calls.
I.e. loop invariant parameters
REG_BR_PROB_BASE/estimated_iterations and regular
parameters REG_BR_PROB_BASE.
Value 0 is reserved for compile time invariants. */
int change_prob;
};
/* Information kept about callgraph edges. */
struct inline_edge_summary
{
@ -233,7 +366,7 @@ struct inline_edge_summary
int call_stmt_time;
/* Depth of loop nest, 0 means no nesting. */
unsigned short int loop_depth;
struct predicate *predicate;
class predicate *predicate;
/* Array indexed by parameters.
0 means that parameter change all the time, REG_BR_PROB_BASE means
that parameter is constant. */