Fix ICE due to condition mismatch between expander and define_insn.
authorliuhongt <hongtao.liu@intel.com>
Tue, 6 Dec 2022 05:21:04 +0000 (13:21 +0800)
committerliuhongt <hongtao.liu@intel.com>
Wed, 7 Dec 2022 01:19:47 +0000 (09:19 +0800)
ice.i:7:1: error: unrecognizable insn:
    7 | }
      | ^
(insn 7 6 8 2 (set (reg:V2SF 84 [ vect__3.8 ])
        (unspec:V2SF [
                (reg:V2SF 86 [ vect__1.7 ])
                (const_int 11 [0xb])
            ] UNSPEC_ROUND)) "ice.i":5:14 -1
     (nil))
during RTL pass: vregs

gcc/ChangeLog:

PR target/107970
* config/i386/mmx.md (btruncv2sf2): Add TARGET_MMX_WITH_SSE to
the condition.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr107970.c: New test.

gcc/config/i386/mmx.md
gcc/testsuite/gcc.target/i386/pr107970.c [new file with mode: 0644]

index 63aff28..c3afc6b 100644 (file)
          [(match_operand:V2SF 1 "register_operand")
           (match_dup 2)]
          UNSPEC_ROUND))]
-  "TARGET_SSE4_1 && !flag_trapping_math"
+  "TARGET_SSE4_1 && !flag_trapping_math
+  && TARGET_MMX_WITH_SSE"
   "operands[2] = GEN_INT (ROUND_TRUNC | ROUND_NO_EXC);")
 
 (define_insn "*mmx_roundv2sf2"
diff --git a/gcc/testsuite/gcc.target/i386/pr107970.c b/gcc/testsuite/gcc.target/i386/pr107970.c
new file mode 100644 (file)
index 0000000..1fbbb14
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile { target ia32 } } */
+/* { dg-options "-Ofast -m3dnow -msse4.1" } */
+
+float *foo_p;
+
+void
+foo(float *__restrict q) {
+  foo_p[0] = __builtin_truncf(q[0]);
+  foo_p[1] = __builtin_truncf(q[1]);
+}