re PR tree-optimization/71423 (wrong code at -Os and above on x86_64-linux-gnu)
authorRichard Biener <rguenther@suse.de>
Tue, 7 Jun 2016 07:30:47 +0000 (07:30 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 7 Jun 2016 07:30:47 +0000 (07:30 +0000)
2016-06-07  Richard Biener  <rguenther@suse.de>

PR middle-end/71423
* match.pd ((X | ~Y) -> Y <= X): Properly invert the comparison
for signed ops.

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

From-SVN: r237166

gcc/ChangeLog
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr71423.c [new file with mode: 0644]

index edc45f5..878ee3a 100644 (file)
@@ -1,3 +1,9 @@
+2016-06-07  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/71423
+       * match.pd ((X | ~Y) -> Y <= X): Properly invert the comparison
+       for signed ops.
+
 2016-06-06  John David Anglin  <danglin@gcc.gnu.org>
 
        * config/pa/pa.md (call): Generate indirect long calls to non-local
index 4d66243..fe71115 100644 (file)
@@ -900,12 +900,16 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   (ne (bit_and:c (bit_not @0) @1) integer_zerop)
   (if (INTEGRAL_TYPE_P (TREE_TYPE (@1))
        && TYPE_PRECISION (TREE_TYPE (@1)) == 1)
-   (lt @0 @1)))
+   (if (TYPE_UNSIGNED (TREE_TYPE (@1)))
+    (lt @0 @1)
+    (gt @0 @1))))
 (simplify
   (ne (bit_ior:c (bit_not @0) @1) integer_zerop)
   (if (INTEGRAL_TYPE_P (TREE_TYPE (@1))
        && TYPE_PRECISION (TREE_TYPE (@1)) == 1)
-   (le @0 @1)))
+   (if (TYPE_UNSIGNED (TREE_TYPE (@1)))
+    (le @0 @1)
+    (ge @0 @1))))
 
 /* ~~x -> x */
 (simplify
index a1a7f19..52bb629 100644 (file)
@@ -1,3 +1,8 @@
+2016-06-07  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/71423
+       * gcc.dg/torture/pr71423.c: New testcase.
+
 2016-06-07  Kugan Vivekanandarajah  <kuganv@linaro.org>
 
        PR middle-end/71408
diff --git a/gcc/testsuite/gcc.dg/torture/pr71423.c b/gcc/testsuite/gcc.dg/torture/pr71423.c
new file mode 100644 (file)
index 0000000..06a613f
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do run } */
+
+struct S1
+{
+  int f1:1;
+};
+
+volatile struct S1 b = { 0 };
+
+int
+main ()
+{
+  char c = b.f1;
+  b.f1 = 1; 
+
+  if (b.f1 > -1 || c)
+    __builtin_abort (); 
+
+  return 0; 
+}