[gcc r12-10050] i386: Fix up *jcc_bt*_mask{,_1} [PR111408]
Jakub Jelinek
jakub@gcc.gnu.org
Sat Dec 16 00:37:52 GMT 2023
https://gcc.gnu.org/g:9cb9cecdb582b44b04e9c49532ddf0065b5c3612
commit r12-10050-g9cb9cecdb582b44b04e9c49532ddf0065b5c3612
Author: Jakub Jelinek <jakub@redhat.com>
Date: Sat Nov 25 10:31:55 2023 +0100
i386: Fix up *jcc_bt*_mask{,_1} [PR111408]
The following testcase is miscompiled in GCC 14 because the
*jcc_bt<mode>_mask and *jcc_bt<SWI48:mode>_mask_1 patterns have just
one argument in (match_operator 0 "bt_comparison_operator" [...])
but as bt_comparison_operator is eq,ne, we need two.
The md readers don't warn about it, after all, some checks can
be done in the predicate rather than specified explicitly, and the
behavior is that anything is accepted as the second argument.
I went through all other i386.md match_operator uses and all others
looked right (extract_operator using 3 operands, all others 2).
I think we'll want to fix this at different spots in older releases
because I think the bug was introduced already in 2008, though most
likely just latent.
2023-11-25 Jakub Jelinek <jakub@redhat.com>
PR target/111408
* config/i386/i386.md (*jcc_bt<mode>_mask): Add (const_int 0) as
expected second operand of bt_comparison_operator.
* gcc.c-torture/execute/pr111408.c: New test.
(cherry picked from commit 9866c98e1015d98b8fc346d7cf73a0070cce5f69)
Diff:
---
gcc/config/i386/i386.md | 3 ++-
gcc/testsuite/gcc.c-torture/execute/pr111408.c | 26 ++++++++++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 464db098dfd..f7cc320d9a0 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -14160,7 +14160,8 @@
(const_int 1)
(and:SI
(match_operand:SI 2 "register_operand")
- (match_operand 3 "const_int_operand")))])
+ (match_operand 3 "const_int_operand")))
+ (const_int 0)])
(label_ref (match_operand 4))
(pc)))
(clobber (reg:CC FLAGS_REG))]
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr111408.c b/gcc/testsuite/gcc.c-torture/execute/pr111408.c
new file mode 100644
index 00000000000..6dfb0a384f1
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr111408.c
@@ -0,0 +1,26 @@
+/* PR target/111408 */
+
+int a, b, c, d;
+short e;
+
+int
+foo ()
+{
+ c = a % (sizeof (int) * 8);
+ if (b & 1 << c)
+ return -1;
+ return 0;
+}
+
+int
+main ()
+{
+ for (; e != 1; e++)
+ {
+ int g = foo ();
+ if (g + d - 9 + d)
+ continue;
+ for (;;)
+ __builtin_abort ();
+ }
+}
More information about the Gcc-cvs
mailing list