This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH][tuples] Fix tree-ssa/ssa-ccp-19.c
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Diego Novillo <dnovillo at google dot com>
- Date: Mon, 14 Jul 2008 12:03:56 +0200 (CEST)
- Subject: [PATCH][tuples] Fix tree-ssa/ssa-ccp-19.c
This fixes tree-ssa/ssa-ccp-19.c - in ccp_fold we handled ADDR_EXPRs
in the GIMPLE_UNARY_RHS case, but ADDR_EXPRs are GIMPLE_SINGLE_RHS.
I'll commit this if it passes bootstrap & regtest.
Richard.
2008-07-14 Richard Guenther <rguenther@suse.de>
* tree-ssa-ccp.c (ccp_fold): Move ADDR_EXPR handing to
GIMPLE_SINGLE_RHS case.
Index: tree-ssa-ccp.c
===================================================================
*** tree-ssa-ccp.c (revision 137780)
--- tree-ssa-ccp.c (working copy)
*************** ccp_fold (gimple stmt)
*** 915,920 ****
--- 915,954 ----
if any. */
return get_value (rhs)->value;
}
+ /* Handle propagating invariant addresses into address operations.
+ The folding we do here matches that in tree-ssa-forwprop.c. */
+ else if (TREE_CODE (rhs) == ADDR_EXPR)
+ {
+ tree *base;
+ base = &TREE_OPERAND (rhs, 0);
+ while (handled_component_p (*base))
+ base = &TREE_OPERAND (*base, 0);
+ if (TREE_CODE (*base) == INDIRECT_REF
+ && TREE_CODE (TREE_OPERAND (*base, 0)) == SSA_NAME)
+ {
+ prop_value_t *val = get_value (TREE_OPERAND (*base, 0));
+ if (val->lattice_val == CONSTANT
+ && TREE_CODE (val->value) == ADDR_EXPR
+ && useless_type_conversion_p
+ (TREE_TYPE (TREE_OPERAND (*base, 0)),
+ TREE_TYPE (val->value))
+ && useless_type_conversion_p
+ (TREE_TYPE (*base),
+ TREE_TYPE (TREE_OPERAND (val->value, 0))))
+ {
+ /* We need to return a new tree, not modify the IL
+ or share parts of it. So play some tricks to
+ avoid manually building it. */
+ tree ret, save = *base;
+ *base = TREE_OPERAND (val->value, 0);
+ ret = unshare_expr (rhs);
+ recompute_tree_invariant_for_addr_expr (ret);
+ *base = save;
+ return ret;
+ }
+ }
+ }
+
else if (do_store_ccp && stmt_makes_single_load (stmt))
{
/* If the RHS is a memory load, see if the VUSEs associated with
*************** ccp_fold (gimple stmt)
*** 957,997 ****
op0 = get_value (op0)->value;
}
- /* Handle propagating invariant addresses into address operations.
- The folding we do here matches that in tree-ssa-forwprop.c. */
- else if (subcode == ADDR_EXPR)
- {
- tree rhs = op0;
- tree *base;
- base = &TREE_OPERAND (rhs, 0);
- while (handled_component_p (*base))
- base = &TREE_OPERAND (*base, 0);
- if (TREE_CODE (*base) == INDIRECT_REF
- && TREE_CODE (TREE_OPERAND (*base, 0)) == SSA_NAME)
- {
- prop_value_t *val = get_value (TREE_OPERAND (*base, 0));
- if (val->lattice_val == CONSTANT
- && TREE_CODE (val->value) == ADDR_EXPR
- && useless_type_conversion_p
- (TREE_TYPE (TREE_OPERAND (*base, 0)),
- TREE_TYPE (val->value))
- && useless_type_conversion_p
- (TREE_TYPE (*base),
- TREE_TYPE (TREE_OPERAND (val->value, 0))))
- {
- /* We need to return a new tree, not modify the IL
- or share parts of it. So play some tricks to
- avoid manually building it. */
- tree ret, save = *base;
- *base = TREE_OPERAND (val->value, 0);
- ret = unshare_expr (rhs);
- recompute_tree_invariant_for_addr_expr (ret);
- *base = save;
- return ret;
- }
- }
- }
-
/* Conversions are useless for CCP purposes if they are
value-preserving. Thus the restrictions that
useless_type_conversion_p places for pointer type conversions
--- 991,996 ----