From 69c4b5c519f0df37e4903992644cc29682721bc1 Mon Sep 17 00:00:00 2001 From: liuhongt Date: Fri, 13 May 2022 15:48:01 +0800 Subject: [PATCH] Fix ICE caused by wrong condition. When d->perm[i] == d->perm[i-1] + 1 and d->perm[i] == nelt, it's not continuous. It should fail if there's more than 2 continuous areas. gcc/ChangeLog: PR target/105587 * config/i386/i386-expand.cc (expand_vec_perm_pslldq_psrldq_por): Fail when (d->perm[i] == d->perm[i-1] + 1) && d->perm[i] == nelt && start != -1. gcc/testsuite/ChangeLog: * gcc.target/i386/pr105587.c: New test. --- gcc/config/i386/i386-expand.cc | 9 ++------- gcc/testsuite/gcc.target/i386/pr105587.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr105587.c diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc index 0fd3028c..806e1f5 100644 --- a/gcc/config/i386/i386-expand.cc +++ b/gcc/config/i386/i386-expand.cc @@ -20963,7 +20963,8 @@ expand_vec_perm_pslldq_psrldq_por (struct expand_vec_perm_d *d, bool pandn) start1 = d->perm[0]; for (i = 1; i < nelt; i++) { - if (d->perm[i] != d->perm[i-1] + 1) + if (d->perm[i] != d->perm[i-1] + 1 + || d->perm[i] == nelt) { if (start2 == -1) { @@ -20973,12 +20974,6 @@ expand_vec_perm_pslldq_psrldq_por (struct expand_vec_perm_d *d, bool pandn) else return false; } - else if (d->perm[i] >= nelt - && start2 == -1) - { - start2 = d->perm[i]; - end1 = d->perm[i-1]; - } } clear_op0 = end1 != nelt - 1; diff --git a/gcc/testsuite/gcc.target/i386/pr105587.c b/gcc/testsuite/gcc.target/i386/pr105587.c new file mode 100644 index 0000000..a5b6ab2 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr105587.c @@ -0,0 +1,11 @@ +#/* { dg-do compile } */ +/* { dg-options "-O3 -msse2 -mno-ssse3" } */ + +extern short arr_108[][4][2][24][12], arr_110[][4][2][24][12]; +void test() { + for (unsigned a = 0; a < 2; a += 2) + for (unsigned b = 4; b < 22; b++) + for (int c = 1; c < 11; c++) + arr_110[0][0][a][b][c] = (unsigned char)arr_108[0][0][a][b][c]; +} + -- 2.7.4