re PR tree-optimization/37508 (ICE in in simplify_truth_ops_using_ranges, at tree...
authorRichard Guenther <rguenther@suse.de>
Tue, 16 Sep 2008 12:31:51 +0000 (12:31 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 16 Sep 2008 12:31:51 +0000 (12:31 +0000)
2008-09-16  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/37508
* tree-vrp.c (simplify_truth_ops_using_ranges): Also allow -1.

* gcc.dg/tree-ssa/pr37508.c: New testcase.

From-SVN: r140387

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

index e46d362..b413f20 100644 (file)
@@ -1,3 +1,8 @@
+2008-09-16  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/37508
+       * tree-vrp.c (simplify_truth_ops_using_ranges): Also allow -1.
+
 2008-09-15  Kaz Kojima  <kkojima@gcc.gnu.org>
 
        * config/sh/sh.md (movsf_ie): Fix length for TARGET_SH2A.
index 0288620..32c4435 100644 (file)
@@ -1,3 +1,8 @@
+2008-09-16  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/37508
+       * gcc.dg/tree-ssa/pr37508.c: New testcase.
+
 2008-09-15  Aldy Hernandez  <aldyh@redhat.com>
 
        * g++.old-deja/g++.brendan/crash16.C: Function name is the correct 
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr37508.c b/gcc/testsuite/gcc.dg/tree-ssa/pr37508.c
new file mode 100644 (file)
index 0000000..f31c594
--- /dev/null
@@ -0,0 +1,48 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-vrp1" } */
+
+struct foo1 {
+  int i:1;
+};
+struct foo2 {
+  unsigned i:1;
+};
+
+int test1 (struct foo1 *x)
+{
+  if (x->i == 0)
+    return 1;
+  else if (x->i == -1)
+    return 1;
+  return 0;
+}
+
+int test2 (struct foo2 *x)
+{
+  if (x->i == 0)
+    return 1;
+  else if (x->i == -1)
+    return 1;
+  return 0;
+}
+
+int test3 (struct foo1 *x)
+{
+  if (x->i == 0)
+    return 1;
+  else if (x->i == 1)
+    return 1;
+  return 0;
+}
+
+int test4 (struct foo2 *x)
+{
+  if (x->i == 0)
+    return 1;
+  else if (x->i == 1)
+    return 1;
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "Folding" 4 "vrp1" { xfail *-*-* } } } */
+/* { dg-final { cleanup-tree-dump "vrp1" } } */
index 31d7f10..fbcda55 100644 (file)
@@ -6331,7 +6331,8 @@ simplify_truth_ops_using_ranges (gimple_stmt_iterator *gsi, gimple stmt)
           /* Exclude anything that should have been already folded.  */
          gcc_assert (rhs_code == EQ_EXPR || rhs_code == NE_EXPR
                      || rhs_code == TRUTH_XOR_EXPR);
-         gcc_assert (integer_zerop (op1) || integer_onep (op1));
+         gcc_assert (integer_zerop (op1) || integer_onep (op1)
+                     || integer_all_onesp (op1));
 
          /* Limit the number of cases we have to consider.  */
          if (rhs_code == EQ_EXPR)