re PR tree-optimization/51760 (ICE in set_lattice_value, at tree-ssa-ccp.c:456)
authorRichard Guenther <rguenther@suse.de>
Thu, 5 Jan 2012 13:41:34 +0000 (13:41 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 5 Jan 2012 13:41:34 +0000 (13:41 +0000)
2012-01-05  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/51760
* tree-ssa-ccp.c (likely_value): Drop UNDEFINED to CONSTANT,
not VARYING.
(bit_value_unop): Handle UNDEFINED operands.
(bit_value_binop): Likewise.

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

From-SVN: r182909

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

index cc91a4c94139266b4a3245e263e8d650bc521835..487ce17aeabe36e6b008948ba28d53d33b95845d 100644 (file)
@@ -1,3 +1,11 @@
+2012-01-05  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/51760
+       * tree-ssa-ccp.c (likely_value): Drop UNDEFINED to CONSTANT,
+       not VARYING.
+       (bit_value_unop): Handle UNDEFINED operands.
+       (bit_value_binop): Likewise.
+
 2012-01-05  Georg-Johann Lay  <avr@gjlay.de>
 
        * config/avr/avr.c (avr_replace_prefix): Remove.
index 7b85906faf6ffdc7fbae6418e24d378d85432323..1064393e13882e6d6a9e70dfe0d0a0a2088e9945 100644 (file)
@@ -1,3 +1,8 @@
+2012-01-05  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/51760
+       * gcc.dg/torture/pr51760.c: New testcase.
+
 2012-01-05  Aldy Hernandez  <aldyh@redhat.com>
 
        PR middle-end/51472
diff --git a/gcc/testsuite/gcc.dg/torture/pr51760.c b/gcc/testsuite/gcc.dg/torture/pr51760.c
new file mode 100644 (file)
index 0000000..ebff2c9
--- /dev/null
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+
+extern inline __attribute__ ((always_inline)) void *
+memmove (void *dest, const void *src, __SIZE_TYPE__ len)
+{
+  return __builtin___memmove_chk (dest, src, len,
+                                 __builtin_object_size (dest, 0));
+}
+
+void
+foo (void)
+{
+  char a[64], *b;
+  for (;;)
+    {
+      memmove (a, b, 0);
+      b = a;
+    }
+}
index 738606fad0234751c3aa437c580c2964119c9d8d..2080c06cce649feb62c7a6bcf23e0f696b8c0588 100644 (file)
@@ -657,9 +657,10 @@ likely_value (gimple stmt)
        }
     }
   /* If there was an UNDEFINED operand but the result may be not UNDEFINED
-     fall back to VARYING even if there were CONSTANT operands.  */
+     fall back to CONSTANT.  During iteration UNDEFINED may still drop
+     to CONSTANT.  */
   if (has_undefined_operand)
-    return VARYING;
+    return CONSTANT;
 
   /* We do not consider virtual operands here -- load from read-only
      memory may have only VARYING virtual operands, but still be
@@ -1368,6 +1369,10 @@ bit_value_unop (enum tree_code code, tree type, tree rhs)
   prop_value_t rval = get_value_for_expr (rhs, true);
   double_int value, mask;
   prop_value_t val;
+
+  if (rval.lattice_val == UNDEFINED)
+    return rval;
+
   gcc_assert ((rval.lattice_val == CONSTANT
               && TREE_CODE (rval.value) == INTEGER_CST)
              || double_int_minus_one_p (rval.mask));
@@ -1399,6 +1404,16 @@ bit_value_binop (enum tree_code code, tree type, tree rhs1, tree rhs2)
   prop_value_t r2val = get_value_for_expr (rhs2, true);
   double_int value, mask;
   prop_value_t val;
+
+  if (r1val.lattice_val == UNDEFINED
+      || r2val.lattice_val == UNDEFINED)
+    {
+      val.lattice_val = VARYING;
+      val.value = NULL_TREE;
+      val.mask = double_int_minus_one;
+      return val;
+    }
+
   gcc_assert ((r1val.lattice_val == CONSTANT
               && TREE_CODE (r1val.value) == INTEGER_CST)
              || double_int_minus_one_p (r1val.mask));