public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-1509] i386: Add missing vector truncate patterns [PR92658].
@ 2023-06-03  0:09 hongtao Liu
  0 siblings, 0 replies; only message in thread
From: hongtao Liu @ 2023-06-03  0:09 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:49337040865269e13cdc2ead276d12ecb2e9f606

commit r14-1509-g49337040865269e13cdc2ead276d12ecb2e9f606
Author: liuhongt <hongtao.liu@intel.com>
Date:   Thu Jun 1 15:08:02 2023 +0800

    i386: Add missing vector truncate patterns [PR92658].
    
    Add missing insn patterns for v2si -> v2hi/v2qi and v2hi-> v2qi vector
    truncate.
    
    gcc/ChangeLog:
    
            PR target/92658
            * config/i386/mmx.md (truncv2hiv2qi2): New define_insn.
            (truncv2si<mode>2): Ditto.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/i386/pr92658-avx512bw-trunc-2.c: New test.

Diff:
---
 gcc/config/i386/mmx.md                             | 21 +++++++++++++++++
 .../gcc.target/i386/pr92658-avx512bw-trunc-2.c     | 27 ++++++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/gcc/config/i386/mmx.md b/gcc/config/i386/mmx.md
index dbcb850ffde..6fbe3909c8b 100644
--- a/gcc/config/i386/mmx.md
+++ b/gcc/config/i386/mmx.md
@@ -3667,6 +3667,27 @@
   DONE;
 })
 
+(define_insn "truncv2hiv2qi2"
+  [(set (match_operand:V2QI 0 "register_operand" "=v")
+	(truncate:V2QI
+	  (match_operand:V2HI 1 "register_operand" "v")))]
+  "TARGET_AVX512VL && TARGET_AVX512BW"
+  "vpmovwb\t{%1, %0|%0, %1}"
+  [(set_attr "type" "ssemov")
+   (set_attr "prefix" "evex")
+   (set_attr "mode" "TI")])
+
+(define_mode_iterator V2QI_V2HI [V2QI V2HI])
+(define_insn "truncv2si<mode>2"
+  [(set (match_operand:V2QI_V2HI 0 "register_operand" "=v")
+	(truncate:V2QI_V2HI
+	  (match_operand:V2SI 1 "register_operand" "v")))]
+  "TARGET_AVX512VL && TARGET_MMX_WITH_SSE"
+  "vpmovd<mmxvecsize>\t{%1, %0|%0, %1}"
+  [(set_attr "type" "ssemov")
+   (set_attr "prefix" "evex")
+   (set_attr "mode" "TI")])
+
 ;; Pack/unpack vector modes
 (define_mode_attr mmxpackmode
   [(V4HI "V8QI") (V2SI "V4HI")])
diff --git a/gcc/testsuite/gcc.target/i386/pr92658-avx512bw-trunc-2.c b/gcc/testsuite/gcc.target/i386/pr92658-avx512bw-trunc-2.c
new file mode 100644
index 00000000000..2f5b7dc5668
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr92658-avx512bw-trunc-2.c
@@ -0,0 +1,27 @@
+/* PR target/92658 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -mavx512bw -mavx512vl" } */
+/* { dg-final { scan-assembler-times "vpmovwb" 1 } } */
+/* { dg-final { scan-assembler-times "vpmovdb" 1 { target { ! ia32 } } } } */
+/* { dg-final { scan-assembler-times "vpmovdw" 1 { target { ! ia32 } } } } */
+
+void
+foo (int* __restrict a, char* b)
+{
+    b[0] = a[0];
+    b[1] = a[1];
+}
+
+void
+foo2 (short* __restrict a, char* b)
+{
+    b[0] = a[0];
+    b[1] = a[1];
+}
+
+void
+foo3 (int* __restrict a, short* b)
+{
+    b[0] = a[0];
+    b[1] = a[1];
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-03  0:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-03  0:09 [gcc r14-1509] i386: Add missing vector truncate patterns [PR92658] hongtao Liu

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).