ipa-reference.c (mark_load): Use get_base_address.

2010-04-07  Richard Guenther  <rguenther@suse.de>

	* ipa-reference.c (mark_load): Use get_base_address.
	(mark_store): Likewise.

	* tree-ssa-ccp.c (gimplify_and_update_call_from_tree): Avoid
	inserting GIMPLE_NOPs into the IL.
	* tree-ssa-structalias.c (get_constraint_for_component_ref):
	Explicitly strip handled components and indirect references.
  
	* fold-const.c (fold_unary_loc): Do not strip qualifiers when
	folding address expressions.
	* gimple.c (gimple_ior_addresses_taken_1): Use get_base_address.
	* tree-ssa-alias.c (decl_refs_may_alias_p): Do not use
	operand_equal_p to compare decls.
	(ptr_deref_may_alias_decl_p): Likewise.
	* tree-ssa-operands.c (get_asm_expr_operands): Simplify
	* tree-ssa-forwprop.c (forward_propagate_into_gimple_cond):
	Handle reversed comparison ops.
	* tree-sra.c (asm_visit_addr): Use get_base_address.
	* ipa-prop.c (visit_store_addr_for_mod_analysis): Use
	get_base_address.
	* ipa-reference.c (mark_address): Use get_base_address.

From-SVN: r158069
This commit is contained in:
Richard Guenther 2010-04-07 15:31:37 +00:00 committed by Richard Biener
parent 5fd5c97a34
commit 2ea9dc6459
11 changed files with 79 additions and 43 deletions

View File

@ -1,3 +1,27 @@
2010-04-07 Richard Guenther <rguenther@suse.de>
* ipa-reference.c (mark_load): Use get_base_address.
(mark_store): Likewise.
* tree-ssa-ccp.c (gimplify_and_update_call_from_tree): Avoid
inserting GIMPLE_NOPs into the IL.
* tree-ssa-structalias.c (get_constraint_for_component_ref):
Explicitly strip handled components and indirect references.
* fold-const.c (fold_unary_loc): Do not strip qualifiers when
folding address expressions.
* gimple.c (gimple_ior_addresses_taken_1): Use get_base_address.
* tree-ssa-alias.c (decl_refs_may_alias_p): Do not use
operand_equal_p to compare decls.
(ptr_deref_may_alias_decl_p): Likewise.
* tree-ssa-operands.c (get_asm_expr_operands): Simplify
* tree-ssa-forwprop.c (forward_propagate_into_gimple_cond):
Handle reversed comparison ops.
* tree-sra.c (asm_visit_addr): Use get_base_address.
* ipa-prop.c (visit_store_addr_for_mod_analysis): Use
get_base_address.
* ipa-reference.c (mark_address): Use get_base_address.
2010-04-07 Richard Guenther <rguenther@suse.de>
* tree-ssa-forwprop.c (forward_propagate_addr_expr):

View File

@ -8561,10 +8561,11 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0)
&mode, &unsignedp, &volatilep, false);
/* If the reference was to a (constant) zero offset, we can use
the address of the base if it has the same base type
as the result type. */
as the result type and the pointer type is unqualified. */
if (! offset && bitpos == 0
&& TYPE_MAIN_VARIANT (TREE_TYPE (type))
&& (TYPE_MAIN_VARIANT (TREE_TYPE (type))
== TYPE_MAIN_VARIANT (TREE_TYPE (base)))
&& TYPE_QUALS (type) == TYPE_UNQUALIFIED)
return fold_convert_loc (loc, type,
build_fold_addr_expr_loc (loc, base));
}

View File

@ -4532,9 +4532,9 @@ gimple_ior_addresses_taken_1 (gimple stmt ATTRIBUTE_UNUSED,
tree addr, void *data)
{
bitmap addresses_taken = (bitmap)data;
while (handled_component_p (addr))
addr = TREE_OPERAND (addr, 0);
if (DECL_P (addr))
addr = get_base_address (addr);
if (addr
&& DECL_P (addr))
{
bitmap_set_bit (addresses_taken, DECL_UID (addr));
return true;

View File

@ -199,7 +199,9 @@ visit_store_addr_for_mod_analysis (gimple stmt ATTRIBUTE_UNUSED,
{
struct ipa_node_params *info = (struct ipa_node_params *) data;
if (TREE_CODE (op) == PARM_DECL)
op = get_base_address (op);
if (op
&& TREE_CODE (op) == PARM_DECL)
{
int index = ipa_get_param_decl_index (info, op);
gcc_assert (index >= 0);

View File

@ -352,9 +352,9 @@ static bool
mark_address (gimple stmt ATTRIBUTE_UNUSED, tree addr,
void *data ATTRIBUTE_UNUSED)
{
while (handled_component_p (addr))
addr = TREE_OPERAND (addr, 0);
mark_address_taken (addr);
addr = get_base_address (addr);
if (addr)
mark_address_taken (addr);
return false;
}
@ -364,7 +364,8 @@ static bool
mark_load (gimple stmt ATTRIBUTE_UNUSED, tree t, void *data)
{
ipa_reference_local_vars_info_t local = (ipa_reference_local_vars_info_t)data;
if (TREE_CODE (t) == VAR_DECL
t = get_base_address (t);
if (t && TREE_CODE (t) == VAR_DECL
&& has_proper_scope_for_analysis (t))
bitmap_set_bit (local->statics_read, DECL_UID (t));
return false;
@ -376,7 +377,8 @@ static bool
mark_store (gimple stmt ATTRIBUTE_UNUSED, tree t, void *data)
{
ipa_reference_local_vars_info_t local = (ipa_reference_local_vars_info_t)data;
if (TREE_CODE (t) == VAR_DECL
t = get_base_address (t);
if (t && TREE_CODE (t) == VAR_DECL
&& has_proper_scope_for_analysis (t))
{
if (local)

View File

@ -1066,7 +1066,9 @@ static bool
asm_visit_addr (gimple stmt ATTRIBUTE_UNUSED, tree op,
void *data ATTRIBUTE_UNUSED)
{
if (DECL_P (op))
op = get_base_address (op);
if (op
&& DECL_P (op))
disqualify_candidate (op, "Non-scalarizable GIMPLE_ASM operand.");
return false;

View File

@ -189,7 +189,7 @@ ptr_deref_may_alias_decl_p (tree ptr, tree decl)
ptr = TREE_OPERAND (base, 0);
else if (base
&& SSA_VAR_P (base))
return operand_equal_p (base, decl, 0);
return base == decl;
else if (base
&& CONSTANT_CLASS_P (base))
return false;
@ -629,7 +629,7 @@ decl_refs_may_alias_p (tree base1,
gcc_assert (SSA_VAR_P (base1) && SSA_VAR_P (base2));
/* If both references are based on different variables, they cannot alias. */
if (!operand_equal_p (base1, base2, 0))
if (base1 != base2)
return false;
/* If both references are based on the same variable, they cannot alias if

View File

@ -3354,6 +3354,7 @@ gimplify_and_update_call_from_tree (gimple_stmt_iterator *si_p, tree expr)
gimple_stmt_iterator i;
gimple_seq stmts = gimple_seq_alloc();
struct gimplify_ctx gctx;
gimple last = NULL;
stmt = gsi_stmt (*si_p);
@ -3375,22 +3376,31 @@ gimplify_and_update_call_from_tree (gimple_stmt_iterator *si_p, tree expr)
/* The replacement can expose previously unreferenced variables. */
for (i = gsi_start (stmts); !gsi_end_p (i); gsi_next (&i))
{
new_stmt = gsi_stmt (i);
find_new_referenced_vars (new_stmt);
gsi_insert_before (si_p, new_stmt, GSI_NEW_STMT);
mark_symbols_for_renaming (new_stmt);
gsi_next (si_p);
}
{
if (last)
{
gsi_insert_before (si_p, last, GSI_NEW_STMT);
gsi_next (si_p);
}
new_stmt = gsi_stmt (i);
find_new_referenced_vars (new_stmt);
mark_symbols_for_renaming (new_stmt);
last = new_stmt;
}
if (lhs == NULL_TREE)
{
new_stmt = gimple_build_nop ();
unlink_stmt_vdef (stmt);
release_defs (stmt);
new_stmt = last;
}
else
{
if (last)
{
gsi_insert_before (si_p, last, GSI_NEW_STMT);
gsi_next (si_p);
}
new_stmt = gimple_build_assign (lhs, tmp);
gimple_set_vuse (new_stmt, gimple_vuse (stmt));
gimple_set_vdef (new_stmt, gimple_vdef (stmt));

View File

@ -398,25 +398,27 @@ forward_propagate_into_gimple_cond (gimple stmt)
do {
tree tmp = NULL_TREE;
tree name, rhs0 = NULL_TREE, rhs1 = NULL_TREE;
tree name = NULL_TREE, rhs0 = NULL_TREE, rhs1 = NULL_TREE;
gimple def_stmt;
bool single_use0_p = false, single_use1_p = false;
enum tree_code code = gimple_cond_code (stmt);
/* We can do tree combining on SSA_NAME and comparison expressions. */
if (TREE_CODE_CLASS (gimple_cond_code (stmt)) == tcc_comparison
&& TREE_CODE (gimple_cond_lhs (stmt)) == SSA_NAME)
if (TREE_CODE_CLASS (gimple_cond_code (stmt)) == tcc_comparison)
{
/* For comparisons use the first operand, that is likely to
simplify comparisons against constants. */
name = gimple_cond_lhs (stmt);
def_stmt = get_prop_source_stmt (name, false, &single_use0_p);
if (def_stmt && can_propagate_from (def_stmt))
if (TREE_CODE (gimple_cond_lhs (stmt)) == SSA_NAME)
{
tree op1 = gimple_cond_rhs (stmt);
rhs0 = rhs_to_tree (TREE_TYPE (op1), def_stmt);
tmp = combine_cond_expr_cond (loc, code, boolean_type_node, rhs0,
op1, !single_use0_p);
name = gimple_cond_lhs (stmt);
def_stmt = get_prop_source_stmt (name, false, &single_use0_p);
if (def_stmt && can_propagate_from (def_stmt))
{
tree op1 = gimple_cond_rhs (stmt);
rhs0 = rhs_to_tree (TREE_TYPE (op1), def_stmt);
tmp = combine_cond_expr_cond (loc, code, boolean_type_node,
rhs0, op1, !single_use0_p);
}
}
/* If that wasn't successful, try the second operand. */
if (tmp == NULL_TREE

View File

@ -798,11 +798,7 @@ get_asm_expr_operands (gimple stmt)
/* Memory operands are addressable. Note that STMT needs the
address of this operand. */
if (!allows_reg && allows_mem)
{
tree t = get_base_address (TREE_VALUE (link));
if (t && DECL_P (t))
mark_address_taken (t);
}
mark_address_taken (TREE_VALUE (link));
get_expr_operands (stmt, &TREE_VALUE (link), opf_def);
}
@ -818,11 +814,7 @@ get_asm_expr_operands (gimple stmt)
/* Memory operands are addressable. Note that STMT needs the
address of this operand. */
if (!allows_reg && allows_mem)
{
tree t = get_base_address (TREE_VALUE (link));
if (t && DECL_P (t))
mark_address_taken (t);
}
mark_address_taken (TREE_VALUE (link));
get_expr_operands (stmt, &TREE_VALUE (link), 0);
}

View File

@ -2951,7 +2951,8 @@ get_constraint_for_component_ref (tree t, VEC(ce_s, heap) **results,
/* Some people like to do cute things like take the address of
&0->a.b */
forzero = t;
while (!SSA_VAR_P (forzero) && !CONSTANT_CLASS_P (forzero))
while (handled_component_p (forzero)
|| INDIRECT_REF_P (forzero))
forzero = TREE_OPERAND (forzero, 0);
if (CONSTANT_CLASS_P (forzero) && integer_zerop (forzero))