public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-10229] i386: Disable ix86_expand_vecop_qihi2 when !TARGET_AVX512BW
@ 2024-05-22  2:27 Haochen Jiang
  0 siblings, 0 replies; only message in thread
From: Haochen Jiang @ 2024-05-22  2:27 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:1ad5c9d524d8fa99773045e75da04ae958012085

commit r14-10229-g1ad5c9d524d8fa99773045e75da04ae958012085
Author: Haochen Jiang <haochen.jiang@intel.com>
Date:   Tue May 21 14:10:43 2024 +0800

    i386: Disable ix86_expand_vecop_qihi2 when !TARGET_AVX512BW
    
    Since vpermq is really slow, we should avoid using it for permutation
    when vpmovwb is not available (needs AVX512BW) for ix86_expand_vecop_qihi2
    and fall back to ix86_expand_vecop_qihi.
    
    gcc/ChangeLog:
    
            PR target/115069
            * config/i386/i386-expand.cc (ix86_expand_vecop_qihi2):
            Do not enable the optimization when AVX512BW is not enabled.
    
    gcc/testsuite/ChangeLog:
    
            PR target/115069
            * gcc.target/i386/pr115069.c: New.

Diff:
---
 gcc/config/i386/i386-expand.cc           | 7 +++++++
 gcc/testsuite/gcc.target/i386/pr115069.c | 9 +++++++++
 2 files changed, 16 insertions(+)

diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
index 8bb8f21e686..51efe6fdd7d 100644
--- a/gcc/config/i386/i386-expand.cc
+++ b/gcc/config/i386/i386-expand.cc
@@ -23963,6 +23963,13 @@ ix86_expand_vecop_qihi2 (enum rtx_code code, rtx dest, rtx op1, rtx op2)
   bool op2vec = GET_MODE_CLASS (GET_MODE (op2)) == MODE_VECTOR_INT;
   bool uns_p = code != ASHIFTRT;
 
+  /* Without VPMOVWB (provided by AVX512BW ISA), the expansion uses the
+     generic permutation to merge the data back into the right place.  This
+     permutation results in VPERMQ, which is slow, so better fall back to
+     ix86_expand_vecop_qihi.  */
+  if (!TARGET_AVX512BW)
+    return false;
+
   if ((qimode == V16QImode && !TARGET_AVX2)
       || (qimode == V32QImode && (!TARGET_AVX512BW || !TARGET_EVEX512))
       /* There are no V64HImode instructions.  */
diff --git a/gcc/testsuite/gcc.target/i386/pr115069.c b/gcc/testsuite/gcc.target/i386/pr115069.c
new file mode 100644
index 00000000000..50a3e033079
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr115069.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mavx2" } */
+/* { dg-final { scan-assembler-not "vpermq" } } */
+
+typedef char v16qi __attribute__((vector_size(16)));
+
+v16qi foo (v16qi a, v16qi b) {
+    return a * b;
+}

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

only message in thread, other threads:[~2024-05-22  2:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-22  2:27 [gcc r14-10229] i386: Disable ix86_expand_vecop_qihi2 when !TARGET_AVX512BW Haochen Jiang

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