aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2013-11-14 09:11:36 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2013-11-14 09:11:36 +0100
commita39ed7e957d3187b18d9b5cecce80515e3905a6a (patch)
tree2cb07580c50f2ab190453cf03949a12dd350e02f
parent46dfed65567e9c2026d072a8fb331e69ae777b3a (diff)
downloadgcc-a39ed7e957d3187b18d9b5cecce80515e3905a6a.zip
gcc-a39ed7e957d3187b18d9b5cecce80515e3905a6a.tar.gz
gcc-a39ed7e957d3187b18d9b5cecce80515e3905a6a.tar.bz2
re PR target/59101 (integer wrong code bug)
PR target/59101 * config/i386/i386.md (*anddi_2): Only allow CCZmode if operands[2] satisfies_constraint_Z that might have bit 31 set. * gcc.c-torture/execute/pr59101.c: New test. Co-Authored-By: Uros Bizjak <ubizjak@gmail.com> From-SVN: r204774
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/config/i386/i386.md13
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/pr59101.c15
4 files changed, 39 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6cb1248..598268e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2013-11-14 Jakub Jelinek <jakub@redhat.com>
+ Uros Bizjak <ubizjak@gmail.com>
+
+ PR target/59101
+ * config/i386/i386.md (*anddi_2): Only allow CCZmode if
+ operands[2] satisfies_constraint_Z that might have bit 31 set.
+
2013-11-13 Jeff Law <law@redhat.com>
PR tree-optimization/59102
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index a37fa64..e23b3b6 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -7978,7 +7978,18 @@
(const_int 0)))
(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,rm")
(and:DI (match_dup 1) (match_dup 2)))]
- "TARGET_64BIT && ix86_match_ccmode (insn, CCNOmode)
+ "TARGET_64BIT
+ && ix86_match_ccmode
+ (insn,
+ /* If we are going to emit andl instead of andq, and the operands[2]
+ constant might have the SImode sign bit set, make sure the sign
+ flag isn't tested, because the instruction will set the sign flag
+ based on bit 31 rather than bit 63. If it isn't CONST_INT,
+ conservatively assume it might have bit 31 set. */
+ (satisfies_constraint_Z (operands[2])
+ && (!CONST_INT_P (operands[2])
+ || val_signbit_known_set_p (SImode, INTVAL (operands[2]))))
+ ? CCZmode : CCNOmode)
&& ix86_binary_operator_ok (AND, DImode, operands)"
"@
and{l}\t{%k2, %k0|%k0, %k2}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7855d73..fffa044 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2013-11-14 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/59101
+ * gcc.c-torture/execute/pr59101.c: New test.
+
2013-11-13 Jeff Law <law@redhat.com>
PR tree-optimization/59102
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr59101.c b/gcc/testsuite/gcc.c-torture/execute/pr59101.c
new file mode 100644
index 0000000..ed6a7e8
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr59101.c
@@ -0,0 +1,15 @@
+/* PR target/59101 */
+
+__attribute__((noinline, noclone)) int
+foo (int a)
+{
+ return (~a & 4102790424LL) > 0 | 6;
+}
+
+int
+main ()
+{
+ if (foo (0) != 7)
+ __builtin_abort ();
+ return 0;
+}