aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Bosscher <stevenb@suse.de>2005-08-17 07:27:47 +0000
committerSteven Bosscher <steven@gcc.gnu.org>2005-08-17 07:27:47 +0000
commita318e3acf8617f5bc13484b821431a02c65af200 (patch)
treef3af9a3da3ad3d027544e4a1675247dac1d70538
parenta7edd66b06ff2f0e6510e3d4c71564f4fd5d0cef (diff)
downloadgcc-a318e3acf8617f5bc13484b821431a02c65af200.zip
gcc-a318e3acf8617f5bc13484b821431a02c65af200.tar.gz
gcc-a318e3acf8617f5bc13484b821431a02c65af200.tar.bz2
re PR tree-optimization/21574 (store_ccp doesn't see through a store.)
PR tree-optimization/21574 * tree-ssa-ccp.c (likely_value): If the right hand side is a constant, return CONSTANT. (ccp_lattice_meet): Use operand_equal_p instead of simple_cst_equal. (ccp_fold, visit_assignment): Likewise. (evaluate_stmt): Handle UNDEFINED and UNKNOWN_VAL the same way. From-SVN: r103206
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr21574.c13
-rw-r--r--gcc/tree-ssa-ccp.c18
4 files changed, 41 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d78ba88..226422a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2005-08-17 Steven Bosscher <stevenb@suse.de>
+
+ PR tree-optimization/21574
+ * tree-ssa-ccp.c (likely_value): If the right hand side is a
+ constant, return CONSTANT.
+ (ccp_lattice_meet): Use operand_equal_p instead of simple_cst_equal.
+ (ccp_fold, visit_assignment): Likewise.
+ (evaluate_stmt): Handle UNDEFINED and UNKNOWN_VAL the same way.
+
2005-08-16 James A. Morrison <phython@gcc.gnu.org>
* c-typeck.c (build_function_call): Call fold_buildN_initializer or
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a8caf51..e631fef 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2005-08-17 Steven Bosscher <stevenb@suse.de>
+
+ PR tree-optimization/21574
+ * gcc.dg/tree-ssa/pr21574.c: New test.
+
2005-08-16 James E Wilson <wilson@specifix.com>
* gcc.dg/large-size-array.c (DIM): Use USHRT_MAX not USHORT_MAX.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr21574.c b/gcc/testsuite/gcc.dg/tree-ssa/pr21574.c
new file mode 100644
index 0000000..6e3a5fb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr21574.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-dominator-opts -fdump-tree-store_ccp" } */
+
+int
+foo (int *p)
+{
+ *p = 0;
+ return *p;
+}
+
+/* The store to *p should be propagated to the return statement. */
+/* { dg-final { scan-tree-dump-times "return 0" 1 "store_ccp" } } */
+/* { dg-final { cleanup-tree-dump "store_ccp" } } */
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 6ec112a..1ff1528 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -473,6 +473,9 @@ likely_value (tree stmt)
&& TREE_CODE (stmt) != SWITCH_EXPR)
return VARYING;
+ if (is_gimple_min_invariant (get_rhs (stmt)))
+ return CONSTANT;
+
found_constant = false;
FOR_EACH_SSA_TREE_OPERAND (use, stmt, iter, SSA_OP_USE|SSA_OP_VUSE)
{
@@ -658,7 +661,8 @@ ccp_lattice_meet (prop_value_t *val1, prop_value_t *val2)
&& val2->lattice_val == CONSTANT
&& simple_cst_equal (val1->value, val2->value) == 1
&& (!do_store_ccp
- || simple_cst_equal (val1->mem_ref, val2->mem_ref) == 1))
+ || (val1->mem_ref && val2->mem_ref
+ && operand_equal_p (val1->mem_ref, val2->mem_ref, 0))))
{
/* Ci M Cj = Ci if (i == j)
Ci M Cj = VARYING if (i != j)
@@ -826,7 +830,8 @@ ccp_fold (tree stmt)
/* If the RHS is a memory load, see if the VUSEs associated with
it are a valid constant for that memory load. */
prop_value_t *val = get_value_loaded_by (stmt, const_val);
- if (val && simple_cst_equal (val->mem_ref, rhs) == 1)
+ if (val && val->mem_ref
+ && operand_equal_p (val->mem_ref, rhs, 0))
return val->value;
else
return NULL_TREE;
@@ -1085,7 +1090,11 @@ evaluate_stmt (tree stmt)
/* The statement produced a nonconstant value. If the statement
had UNDEFINED operands, then the result of the statement
should be UNDEFINED. Otherwise, the statement is VARYING. */
- val.lattice_val = (likelyvalue == UNDEFINED) ? UNDEFINED : VARYING;
+ if (likelyvalue == UNDEFINED || likelyvalue == UNKNOWN_VAL)
+ val.lattice_val = likelyvalue;
+ else
+ val.lattice_val = VARYING;
+
val.value = NULL_TREE;
}
@@ -1122,7 +1131,8 @@ visit_assignment (tree stmt, tree *output_p)
we can propagate the value on the RHS. */
prop_value_t *nval = get_value_loaded_by (stmt, const_val);
- if (nval && simple_cst_equal (nval->mem_ref, rhs) == 1)
+ if (nval && nval->mem_ref
+ && operand_equal_p (nval->mem_ref, rhs, 0))
val = *nval;
else
val = evaluate_stmt (stmt);