]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2015-01-29 Richard Biener <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 29 Jan 2015 13:50:37 +0000 (13:50 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 29 Jan 2015 13:50:37 +0000 (13:50 +0000)
PR tree-optimization/64853
* tree-vrp.c (vrp_valueize_1): Do not return anything if the
stmt will get simulated again.
* tree-ssa-ccp.c (valueize_op_1): Likewise.

* gcc.dg/torture/pr64853.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@220247 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr64853.c [new file with mode: 0644]
gcc/tree-ssa-ccp.c
gcc/tree-vrp.c

index 97316fa9634e1517de5f4d9ca906e5fd891bf495..be590e5aa991edad0cc86e7794b55dca249d0d67 100644 (file)
@@ -1,3 +1,10 @@
+2015-01-29  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/64853
+       * tree-vrp.c (vrp_valueize_1): Do not return anything if the
+       stmt will get simulated again.
+       * tree-ssa-ccp.c (valueize_op_1): Likewise.
+
 2015-01-29  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        * config/arm/arm.c (arm_emit_multi_reg_pop): Simplify definition of
index cda948d64d3c1dcd6f274436a9e578f253730a19..8409b469634f02814f4d91749b9e6059fb9946c0 100644 (file)
@@ -1,3 +1,8 @@
+2015-01-29  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/64853
+       * gcc.dg/torture/pr64853.c: New testcase.
+
 2015-01-29  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/64844
diff --git a/gcc/testsuite/gcc.dg/torture/pr64853.c b/gcc/testsuite/gcc.dg/torture/pr64853.c
new file mode 100644 (file)
index 0000000..620f99d
--- /dev/null
@@ -0,0 +1,44 @@
+/* { dg-do run } */
+
+struct S
+{
+  int f1;
+};
+
+static struct S a = { 1 };
+char b;
+static unsigned char *c = &b;
+int d, e, f;
+
+int
+fn1 (int p)
+{
+  return 0 ? 0 : p - 1;
+}
+
+static int
+fn2 (struct S p)
+{
+  int g = 200;
+  for (e = 4; e; e = fn1 (e))
+    {
+      for (; d; d++)
+       ;
+      *c &= p.f1 & g;
+      g = --*c;
+      if (f)
+       return 0;
+    }
+  return 0;
+}
+
+int
+main ()
+{
+  fn2 (a);
+
+  if (b != 0) 
+    __builtin_abort (); 
+
+  return 0;
+}
index 43336fad6e074f0283dac2fba83023616fabb9f8..a576bd118b34e44712c8f49d59965390c5f7013a 100644 (file)
@@ -1141,15 +1141,15 @@ valueize_op_1 (tree op)
 {
   if (TREE_CODE (op) == SSA_NAME)
     {
-      tree tem = get_constant_value (op);
-      if (tem)
-       return tem;
       /* If the definition may be simulated again we cannot follow
          this SSA edge as the SSA propagator does not necessarily
         re-visit the use.  */
       gimple def_stmt = SSA_NAME_DEF_STMT (op);
       if (prop_simulate_again_p (def_stmt))
        return NULL_TREE;
+      tree tem = get_constant_value (op);
+      if (tem)
+       return tem;
     }
   return op;
 }
index 2bc22c6b57b271321ca8abb53290ca4459052958..ef1c21db973438a02f27956c401d710b315cd280 100644 (file)
@@ -7092,15 +7092,15 @@ vrp_valueize_1 (tree name)
 {
   if (TREE_CODE (name) == SSA_NAME)
     {
-      value_range_t *vr = get_value_range (name);
-      if (range_int_cst_singleton_p (vr))
-       return vr->min;
       /* If the definition may be simulated again we cannot follow
          this SSA edge as the SSA propagator does not necessarily
         re-visit the use.  */
       gimple def_stmt = SSA_NAME_DEF_STMT (name);
       if (prop_simulate_again_p (def_stmt))
        return NULL_TREE;
+      value_range_t *vr = get_value_range (name);
+      if (range_int_cst_singleton_p (vr))
+       return vr->min;
     }
   return name;
 }