Hi, while looking into inliner's behaviour on sreal I noticed that const bulitins arenot predicted to become constant when their parameters are. This patch implement that. It is not fully optimal, because cost of the const call will be still accounted, but it enables better propagation of invariantness.
Also inliner probably should make difference between constant and invariant, but that is for next stage1. Bootstrapped/regtested x86_64-linux, will commit it after bit of further testing on Firefox and tramp3d. Honza * ipa-inline-analysis.c (will_be_nonconstant_predicate): Consider return values of const calls as constants. (estimate_function_body_sizes): Expect calls to have false predicates. Index: ipa-inline-analysis.c =================================================================== --- ipa-inline-analysis.c (revision 218791) +++ ipa-inline-analysis.c (working copy) @@ -2036,12 +2036,12 @@ will_be_nonconstant_predicate (struct ip struct agg_position_info aggpos; /* What statments might be optimized away - when their arguments are constant - TODO: also trivial builtins. - builtin_constant_p is already handled later. */ + when their arguments are constant. */ if (gimple_code (stmt) != GIMPLE_ASSIGN && gimple_code (stmt) != GIMPLE_COND - && gimple_code (stmt) != GIMPLE_SWITCH) + && gimple_code (stmt) != GIMPLE_SWITCH + && (gimple_code (stmt) != GIMPLE_CALL + || !(gimple_call_flags (stmt) & ECF_CONST))) return p; /* Stores will stay anyway. */ @@ -2101,9 +2101,10 @@ will_be_nonconstant_predicate (struct ip p = nonconstant_names[SSA_NAME_VERSION (use)]; op_non_const = or_predicates (summary->conds, &p, &op_non_const); } - if (gimple_code (stmt) == GIMPLE_ASSIGN - && TREE_CODE (gimple_assign_lhs (stmt)) == SSA_NAME) - nonconstant_names[SSA_NAME_VERSION (gimple_assign_lhs (stmt))] + if ((gimple_code (stmt) == GIMPLE_ASSIGN || gimple_code (stmt) == GIMPLE_CALL) + && gimple_op (stmt, 0) + && TREE_CODE (gimple_op (stmt, 0)) == SSA_NAME) + nonconstant_names[SSA_NAME_VERSION (gimple_op (stmt, 0))] = op_non_const; return op_non_const; } @@ -2683,7 +2684,9 @@ estimate_function_body_sizes (struct cgr else p = true_predicate (); - if (!false_predicate_p (&p)) + if (!false_predicate_p (&p) + || (is_gimple_call (stmt) + && !false_predicate_p (&bb_predicate))) { time += this_time; size += this_size;