re PR rtl-optimization/64957 (wrong code at -O1, -O2 and -O3 on x86_64-linux-gnu)
authorJakub Jelinek <jakub@redhat.com>
Fri, 6 Feb 2015 11:36:34 +0000 (12:36 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 6 Feb 2015 11:36:34 +0000 (12:36 +0100)
PR rtl-optimization/64957
PR debug/64817
* simplify-rtx.c (simplify_binary_operation_1): Use ~cval for
IOR rather than for AND.

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

From-SVN: r220475

gcc/ChangeLog
gcc/simplify-rtx.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr64957.c [new file with mode: 0644]

index 7cf5049d0dbbe7ea457e562778caead5f8ce0b99..3a5d7a23a8f5a45205bc25bb4153f97ef9f3eba7 100644 (file)
@@ -1,3 +1,10 @@
+2015-02-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/64957
+       PR debug/64817
+       * simplify-rtx.c (simplify_binary_operation_1): Use ~cval for
+       IOR rather than for AND.
+
 2015-02-06  Eric Botcazou  <ebotcazou@adacore.com>
 
        PR target/62631
index 04452c6e4478c22ee86dbdc93f20d3b650cf8fa4..a003b4179aa692700237448367955e13da3766e6 100644 (file)
@@ -2731,9 +2731,9 @@ simplify_binary_operation_1 (enum rtx_code code, machine_mode mode,
          HOST_WIDE_INT xcval;
 
          if (op == IOR)
-           xcval = cval;
-         else
            xcval = ~cval;
+         else
+           xcval = cval;
 
          return simplify_gen_binary (XOR, mode,
                                      simplify_gen_binary (op, mode, a, c),
index 55715adca669e1e59bfd1a161b7aa8f170fd4228..48a804f00a668c3759ff2f0bba1618e8ebb3d95e 100644 (file)
@@ -1,3 +1,9 @@
+2015-02-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/64957
+       PR debug/64817
+       * gcc.c-torture/execute/pr64957.c: New test.
+
 2015-02-05  Jeff Law  <law@redhat.com>
 
        PR target/17306
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr64957.c b/gcc/testsuite/gcc.c-torture/execute/pr64957.c
new file mode 100644 (file)
index 0000000..2a70e17
--- /dev/null
@@ -0,0 +1,23 @@
+/* PR rtl-optimization/64957 */
+
+__attribute__((noinline, noclone)) int
+foo (int b)
+{
+  return (((b ^ 5) | 1) ^ 5) | 1;
+}
+
+__attribute__((noinline, noclone)) int
+bar (int b)
+{
+  return (((b ^ ~5) & ~1) ^ ~5) & ~1;
+}
+
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 16; i++)
+    if (foo (i) != (i | 1) || bar (i) != (i & ~1))
+      __builtin_abort ();
+  return 0;
+}