There is no need to set mode attribute to XImode since ix86_output_ssemov
can properly encode xmm16-xmm31 registers with and without AVX512VL.

gcc/

        PR target/89229
        * config/i386/i386.md (*movti_internal): Call ix86_output_ssemov
        for TYPE_SSEMOV.  Remove ext_sse_reg_operand and TARGET_AVX512VL
        check.

gcc/testsuite/

        PR target/89229
        * gcc.target/i386/pr89229-2a.c: New test.
        * gcc.target/i386/pr89229-2b.c: Likewise.
        * gcc.target/i386/pr89229-2c.c: Likewise.
---
 gcc/config/i386/i386.md                    | 28 +---------------------
 gcc/testsuite/gcc.target/i386/pr89229-2a.c | 15 ++++++++++++
 gcc/testsuite/gcc.target/i386/pr89229-2b.c | 13 ++++++++++
 gcc/testsuite/gcc.target/i386/pr89229-2c.c |  6 +++++
 4 files changed, 35 insertions(+), 27 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr89229-2a.c
 create mode 100644 gcc/testsuite/gcc.target/i386/pr89229-2b.c
 create mode 100644 gcc/testsuite/gcc.target/i386/pr89229-2c.c

diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 9e9b17d0913..5607d1ecddc 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -1955,27 +1955,7 @@ (define_insn "*movti_internal"
       return standard_sse_constant_opcode (insn, operands);
 
     case TYPE_SSEMOV:
-      /* TDmode values are passed as TImode on the stack.  Moving them
-        to stack may result in unaligned memory access.  */
-      if (misaligned_operand (operands[0], TImode)
-         || misaligned_operand (operands[1], TImode))
-       {
-         if (get_attr_mode (insn) == MODE_V4SF)
-           return "%vmovups\t{%1, %0|%0, %1}";
-         else if (get_attr_mode (insn) == MODE_XI)
-           return "vmovdqu32\t{%1, %0|%0, %1}";
-         else
-           return "%vmovdqu\t{%1, %0|%0, %1}";
-       }
-      else
-       {
-         if (get_attr_mode (insn) == MODE_V4SF)
-           return "%vmovaps\t{%1, %0|%0, %1}";
-         else if (get_attr_mode (insn) == MODE_XI)
-           return "vmovdqa32\t{%1, %0|%0, %1}";
-         else
-           return "%vmovdqa\t{%1, %0|%0, %1}";
-       }
+      return ix86_output_ssemov (insn, operands);
 
     default:
       gcc_unreachable ();
@@ -2002,12 +1982,6 @@ (define_insn "*movti_internal"
    (set (attr "mode")
        (cond [(eq_attr "alternative" "0,1")
                 (const_string "DI")
-              (ior (match_operand 0 "ext_sse_reg_operand")
-                   (match_operand 1 "ext_sse_reg_operand"))
-                (const_string "XI")
-              (and (eq_attr "alternative" "3")
-                   (match_test "TARGET_AVX512VL"))
-                (const_string "XI")
               (match_test "TARGET_AVX")
                 (const_string "TI")
               (ior (not (match_test "TARGET_SSE2"))
diff --git a/gcc/testsuite/gcc.target/i386/pr89229-2a.c 
b/gcc/testsuite/gcc.target/i386/pr89229-2a.c
new file mode 100644
index 00000000000..0cf78039481
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr89229-2a.c
@@ -0,0 +1,15 @@
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-O2 -march=skylake-avx512" } */
+
+typedef __int128 __m128t __attribute__ ((__vector_size__ (16),
+                                        __may_alias__));
+
+__m128t
+foo1 (void)
+{
+  register __int128 xmm16 __asm ("xmm16") = (__int128) -1;
+  asm volatile ("" : "+v" (xmm16));
+  return (__m128t) xmm16;
+}
+
+/* { dg-final { scan-assembler-not "%zmm\[0-9\]+" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr89229-2b.c 
b/gcc/testsuite/gcc.target/i386/pr89229-2b.c
new file mode 100644
index 00000000000..8d5d6c41d30
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr89229-2b.c
@@ -0,0 +1,13 @@
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-O2 -march=skylake-avx512 -mno-avx512vl" } */
+
+typedef __int128 __m128t __attribute__ ((__vector_size__ (16),
+                                        __may_alias__));
+
+__m128t
+foo1 (void)
+{
+  register __int128 xmm16 __asm ("xmm16") = (__int128) -1; /* { dg-error 
"register specified for 'xmm16'" } */
+  asm volatile ("" : "+v" (xmm16));
+  return (__m128t) xmm16;
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr89229-2c.c 
b/gcc/testsuite/gcc.target/i386/pr89229-2c.c
new file mode 100644
index 00000000000..218da46dcd0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr89229-2c.c
@@ -0,0 +1,6 @@
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-O2 -march=skylake-avx512 -mprefer-vector-width=512" } */
+
+#include "pr89229-2a.c"
+
+/* { dg-final { scan-assembler-not "%zmm\[0-9\]+" } } */
-- 
2.24.1

Reply via email to