aboutsummaryrefslogtreecommitdiff
path: root/gcc/config
diff options
context:
space:
mode:
authorliuhongt <hongtao.liu@intel.com>2022-10-18 16:58:52 +0800
committerliuhongt <hongtao.liu@intel.com>2022-10-19 14:09:09 +0800
commit1442e2031e0bc2d0a5bf88ef3c92c5410e044bab (patch)
treecaea9f6fc394c360fb2888ac78817ecc5b21202a /gcc/config
parent21de009f741923bc2dcfaa80877b3725e90ab96c (diff)
downloadgcc-1442e2031e0bc2d0a5bf88ef3c92c5410e044bab.zip
gcc-1442e2031e0bc2d0a5bf88ef3c92c5410e044bab.tar.gz
gcc-1442e2031e0bc2d0a5bf88ef3c92c5410e044bab.tar.bz2
Canonicalize vec_perm index to make the first index come from the first vector.
Fix unexpected non-canon form from gimple vector selector. gcc/ChangeLog: PR target/107271 * config/i386/i386-expand.cc (ix86_vec_perm_index_canon): New. (expand_vec_perm_shufps_shufps): Call ix86_vec_perm_index_canon gcc/testsuite/ChangeLog: * gcc.target/i386/pr107271.c: New test.
Diffstat (limited to 'gcc/config')
-rw-r--r--gcc/config/i386/i386-expand.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
index a0f8a98..70fd82b 100644
--- a/gcc/config/i386/i386-expand.cc
+++ b/gcc/config/i386/i386-expand.cc
@@ -19604,6 +19604,22 @@ expand_vec_perm_1 (struct expand_vec_perm_d *d)
return false;
}
+/* Canonicalize vec_perm index to make the first index
+ always comes from the first vector. */
+static void
+ix86_vec_perm_index_canon (struct expand_vec_perm_d *d)
+{
+ unsigned nelt = d->nelt;
+ if (d->perm[0] < nelt)
+ return;
+
+ for (unsigned i = 0; i != nelt; i++)
+ d->perm[i] = (d->perm[i] + nelt) % (2 * nelt);
+
+ std::swap (d->op0, d->op1);
+ return;
+}
+
/* A subroutine of ix86_expand_vec_perm_const_1. Try to implement D
in terms of a pair of shufps+ shufps/pshufd instructions. */
static bool
@@ -19621,6 +19637,7 @@ expand_vec_perm_shufps_shufps (struct expand_vec_perm_d *d)
if (d->testing_p)
return true;
+ ix86_vec_perm_index_canon (d);
for (i = 0; i < 4; ++i)
count += d->perm[i] > 3 ? 1 : 0;