aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2015-02-06 12:36:34 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2015-02-06 12:36:34 +0100
commitd26ac279bca9a071d5f4de994b1dc8cd214335c2 (patch)
tree17b7f8c04d0c1ad9c59b006581789e3b4b2fd576
parente3a7c6cf721d52efe1a80b83149edd8c66568841 (diff)
downloadgcc-d26ac279bca9a071d5f4de994b1dc8cd214335c2.zip
gcc-d26ac279bca9a071d5f4de994b1dc8cd214335c2.tar.gz
gcc-d26ac279bca9a071d5f4de994b1dc8cd214335c2.tar.bz2
re PR rtl-optimization/64957 (wrong code at -O1, -O2 and -O3 on x86_64-linux-gnu)
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
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/simplify-rtx.c4
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr64957.c23
4 files changed, 38 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7cf5049..3a5d7a2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 04452c6..a003b41 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -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),
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 55715ad..48a804f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..2a70e17
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr64957.c
@@ -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;
+}