[gcc r11-11159] i386: Fix mmx.md signbit expanders [PR112816]

Jakub Jelinek jakub@gcc.gnu.org
Tue Dec 19 09:45:28 GMT 2023


https://gcc.gnu.org/g:d9b7e78dae13945dd9b296f2cca67650da0f869d

commit r11-11159-gd9b7e78dae13945dd9b296f2cca67650da0f869d
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Dec 19 10:24:33 2023 +0100

    i386: Fix mmx.md signbit expanders [PR112816]
    
    Apparently when looking for "signbit<mode>2" vector expanders, I've only
    looked at sse.md and forgot mmx.md, which has another one and the
    following patch still ICEd.
    
    2023-12-19  Jakub Jelinek  <jakub@redhat.com>
    
            PR target/112816
            * config/i386/mmx.md (signbitv2sf2): Force operands[1] into a REG.
    
            * gcc.target/i386/sse2-pr112816-2.c: New test.
    
    (cherry picked from commit 80e1375ed7a7a05a5a60a57e72c5ad5eba005798)

Diff:
---
 gcc/config/i386/mmx.md                          |  5 ++++-
 gcc/testsuite/gcc.target/i386/sse2-pr112816-2.c | 16 ++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md
index 4c2b724dc6f..a5e9c896ef6 100644
--- a/gcc/config/i386/mmx.md
+++ b/gcc/config/i386/mmx.md
@@ -787,7 +787,10 @@
 	    (match_operand:V2SF 1 "register_operand") 0)
 	  (match_dup 2)))]
   "TARGET_MMX_WITH_SSE"
-  "operands[2] = GEN_INT (GET_MODE_UNIT_BITSIZE (V2SFmode)-1);")
+{
+  operands[1] = force_reg (V2SFmode, operands[1]);
+  operands[2] = GEN_INT (GET_MODE_UNIT_BITSIZE (V2SFmode)-1);
+})
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;
diff --git a/gcc/testsuite/gcc.target/i386/sse2-pr112816-2.c b/gcc/testsuite/gcc.target/i386/sse2-pr112816-2.c
new file mode 100644
index 00000000000..2bfae8fa58e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/sse2-pr112816-2.c
@@ -0,0 +1,16 @@
+/* PR target/112816 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -msse2" } */
+
+#define N 2
+struct S { float x[N]; };
+struct T { int x[N]; };
+
+struct T
+foo (struct S x)
+{
+  struct T res;
+  for (int i = 0; i < N; ++i)
+    res.x[i] = __builtin_signbit (x.x[i]) ? -1 : 0;
+  return res;
+}


More information about the Gcc-cvs mailing list