public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-11111] i386: Wrong code with __builtin_parityl [PR112672]
@ 2023-11-24 14:59 Uros Bizjak
0 siblings, 0 replies; only message in thread
From: Uros Bizjak @ 2023-11-24 14:59 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:422e30e4d5ca2f26f77e7c90e09658408c07a23c
commit r11-11111-g422e30e4d5ca2f26f77e7c90e09658408c07a23c
Author: Uros Bizjak <ubizjak@gmail.com>
Date: Thu Nov 23 16:17:57 2023 +0100
i386: Wrong code with __builtin_parityl [PR112672]
gen_parityhi2_cmp instruction clobbers its input operand, so use
a temporary register in the call to gen_parityhi2_cmp.
PR target/112672
gcc/ChangeLog:
* config/i386/i386.md (parityhi2):
Use temporary register in the call to gen_parityhi2_cmp.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr112672.c: New test.
(cherry picked from commit b2d17bdd45b582b93e89c00b04763a45f97d7a34)
Diff:
---
gcc/config/i386/i386.md | 4 +++-
gcc/testsuite/gcc.target/i386/pr112672.c | 23 +++++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 39b04861064..1f0ae023f7e 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -15315,8 +15315,10 @@
"! TARGET_POPCNT"
{
rtx scratch = gen_reg_rtx (QImode);
+ rtx tmp = gen_reg_rtx (HImode);
- emit_insn (gen_parityhi2_cmp (operands[1]));
+ emit_move_insn (tmp, operands[1]);
+ emit_insn (gen_parityhi2_cmp (tmp));
ix86_expand_setcc (scratch, ORDERED,
gen_rtx_REG (CCmode, FLAGS_REG), const0_rtx);
diff --git a/gcc/testsuite/gcc.target/i386/pr112672.c b/gcc/testsuite/gcc.target/i386/pr112672.c
new file mode 100644
index 00000000000..583e9fdfb8b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr112672.c
@@ -0,0 +1,23 @@
+/* PR target/112672 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+typedef unsigned short u16;
+
+u16 g = 254;
+
+static inline u16
+foo (u16 u)
+{
+ u *= g;
+ return u + __builtin_parityl (u);
+}
+
+int
+main (void)
+{
+ u16 x = foo (4);
+ if (x != 4 * 254 + 1)
+ __builtin_abort ();
+ return 0;
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-11-24 14:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-24 14:59 [gcc r11-11111] i386: Wrong code with __builtin_parityl [PR112672] Uros Bizjak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).