2011-09-21 Jan Hubicka <jh@suse.cz>
+ * ipa-inline-analsis.c (compute_inline_parameters): Set
+ cfun and current_function_decl.
+
+2011-09-21 Jan Hubicka <jh@suse.cz>
+
+ * ipa-inline-analysis.c (set_cond_stmt_execution_predicate): Allow
+ handled components in parameter of builtin_constant_p.
+ (will_be_nonconstant_predicate): Allow loads of non-SSA parameters.
+
+2011-09-21 Jan Hubicka <jh@suse.cz>
+
* ipa-inline.c (relative_time_benefit): Fix wrong bracketting.
* ipa-inline.h (estimate_edge_time): Fix pasto.
* ipa-inline-analysis.c (do_estiamte_edge_time): Remove capping.
gimple set_stmt;
tree op2;
tree parm;
+ tree base;
last = last_stmt (bb);
if (!last
|| gimple_call_num_args (set_stmt) != 1)
return;
op2 = gimple_call_arg (set_stmt, 0);
- parm = unmodified_parm (set_stmt, op2);
+ base = get_base_address (op2);
+ parm = unmodified_parm (set_stmt, base ? base : op2);
if (!parm)
return;
index = ipa_get_param_decl_index (info, parm);
ssa_op_iter iter;
tree use;
struct predicate op_non_const;
+ bool is_load;
/* What statments might be optimized away
when their arguments are constant
&& gimple_code (stmt) != GIMPLE_SWITCH)
return p;
- /* Stores and loads will stay anyway.
- TODO: Constant memory accesses could be handled here, too. */
- if (gimple_vuse (stmt))
+ /* Stores will stay anyway. */
+ if (gimple_vdef (stmt))
return p;
+ is_load = gimple_vuse (stmt) != NULL;
+
+ /* Loads can be optimized when the value is known. */
+ if (is_load)
+ {
+ tree op = gimple_assign_rhs1 (stmt);
+ tree base = get_base_address (op);
+ tree parm;
+
+ gcc_assert (gimple_assign_single_p (stmt));
+ if (!base)
+ return p;
+ parm = unmodified_parm (stmt, base);
+ if (!parm )
+ return p;
+ if (ipa_get_param_decl_index (info, parm) < 0)
+ return p;
+ }
+
/* See if we understand all operands before we start
adding conditionals. */
FOR_EACH_SSA_TREE_OPERAND (use, stmt, iter, SSA_OP_USE)
return p;
}
op_non_const = false_predicate ();
+ if (is_load)
+ {
+ tree parm = unmodified_parm
+ (stmt, get_base_address (gimple_assign_rhs1 (stmt)));
+ p = add_condition (summary,
+ ipa_get_param_decl_index (info, parm),
+ IS_NOT_CONSTANT, NULL);
+ op_non_const = or_predicates (summary->conds, &p, &op_non_const);
+ }
FOR_EACH_SSA_TREE_OPERAND (use, stmt, iter, SSA_OP_USE)
{
tree parm = unmodified_parm (stmt, use);
HOST_WIDE_INT self_stack_size;
struct cgraph_edge *e;
struct inline_summary *info;
+ tree old_decl = current_function_decl;
gcc_assert (!node->global.inlined_to);
return;
}
+ /* Even is_gimple_min_invariant rely on current_function_decl. */
+ current_function_decl = node->decl;
+ push_cfun (DECL_STRUCT_FUNCTION (node->decl));
+
/* Estimate the stack size for the function if we're optimizing. */
self_stack_size = optimize ? estimated_stack_frame_size (node) : 0;
info->estimated_self_stack_size = self_stack_size;
info->size = info->self_size;
info->stack_frame_offset = 0;
info->estimated_stack_size = info->estimated_self_stack_size;
+ current_function_decl = old_decl;
+ pop_cfun ();
}