re PR tree-optimization/58364 (likely wrong code bug)
authorJakub Jelinek <jakub@redhat.com>
Mon, 9 Sep 2013 17:09:59 +0000 (19:09 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 9 Sep 2013 17:09:59 +0000 (19:09 +0200)
PR tree-optimization/58364
* tree-ssa-reassoc.c (init_range_entry): For BIT_NOT_EXPR on
BOOLEAN_TYPE, only invert in_p and continue with arg0 if
the current range can't be an unconditional true or false.

* gcc.c-torture/execute/pr58364.c: New test.

From-SVN: r202409

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr58364.c [new file with mode: 0644]
gcc/tree-ssa-reassoc.c

index 3edd10076b7d681a43266b7f8e27cace0608173e..dd9a3e0cbc1b21ee161804182ad3bb8b99303326 100644 (file)
@@ -1,3 +1,10 @@
+2013-09-09  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/58364
+       * tree-ssa-reassoc.c (init_range_entry): For BIT_NOT_EXPR on
+       BOOLEAN_TYPE, only invert in_p and continue with arg0 if
+       the current range can't be an unconditional true or false.
+
 2013-09-09  James Greenhalgh  <james.greenhalgh@arm.com>
 
        * config/aarch64/arm_neon.h (vrsqrte_f64): Fix parameter type.
index 177ed3fdfade83a86d551d64c1da9ee33e723c86..befd28d26909e9639a6db3c96952b069d7955f80 100644 (file)
@@ -1,3 +1,8 @@
+2013-09-09  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/58364
+       * gcc.c-torture/execute/pr58364.c: New test.
+
 2013-09-09  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/43452
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr58364.c b/gcc/testsuite/gcc.c-torture/execute/pr58364.c
new file mode 100644 (file)
index 0000000..59ad7b4
--- /dev/null
@@ -0,0 +1,17 @@
+/* PR tree-optimization/58364 */
+
+int a = 1, b, c;
+
+int
+foo (int x)
+{
+  return x < 0 ? 1 : x;
+}
+
+int
+main ()
+{
+  if (foo (a > c == (b = 0)))
+    __builtin_abort ();
+  return 0;
+}
index 03c6c5dbfa4bb365d3f51c0a461495c804c67d98..b4a3b0a2df9fc7762ffe6644a4b6d7207725b3e1 100644 (file)
@@ -1801,7 +1801,14 @@ init_range_entry (struct range_entry *r, tree exp, gimple stmt)
       switch (code)
        {
        case BIT_NOT_EXPR:
-         if (TREE_CODE (TREE_TYPE (exp)) == BOOLEAN_TYPE)
+         if (TREE_CODE (TREE_TYPE (exp)) == BOOLEAN_TYPE
+             /* Ensure the range is either +[-,0], +[0,0],
+                -[-,0], -[0,0] or +[1,-], +[1,1], -[1,-] or
+                -[1,1].  If it is e.g. +[-,-] or -[-,-]
+                or similar expression of unconditional true or
+                false, it should not be negated.  */
+             && ((high && integer_zerop (high))
+                 || (low && integer_onep (low))))
            {
              in_p = !in_p;
              exp = arg0;