Adjust testcase for the regressed testcases after obsolete of vcond{,u,eq}.

> Richard suggests that we implement the "obvious" transforms like
> inversion in the middle-end but if for example unsigned compares
> are not supported the us_minus + eq + negative trick isn't on
> that list.
>
> The main reason to restrict vec_cmp would be to avoid
> a <= b ? c : d going with an unsupported vec_cmp but instead
> do a > b ? d : c - the alternative is trying to fix this
> on the RTL side via combine.  I understand the non-native

Yes, I have a patch which can fix most regressions via pattern match
in combine.
Still there is a situation that is difficult to deal with, mainly the
optimization w/o sse4.1 . Because pblendvb/blendvps/blendvpd only
exists under sse4.1, w/o sse4.1, it takes 3
instructions (pand,pandn,por) to simulate the vcond_mask, and the
combine matches up to 4 instructions, which makes it currently
impossible to use the combine to recover those optimizations in the
vcond{,u,eq}.i.e min/max.

In the case of sse 4.1 and above, there is basically no regression anymore.

the regression testcases w/o sse4.1

FAIL: g++.target/i386/pr100637-1b.C  -std=gnu++14  scan-assembler-times pcmpeqb 2
FAIL: g++.target/i386/pr100637-1b.C  -std=gnu++17  scan-assembler-times pcmpeqb 2
FAIL: g++.target/i386/pr100637-1b.C  -std=gnu++20  scan-assembler-times pcmpeqb 2
FAIL: g++.target/i386/pr100637-1b.C  -std=gnu++98  scan-assembler-times pcmpeqb 2
FAIL: g++.target/i386/pr100637-1w.C  -std=gnu++14  scan-assembler-times pcmpeqw 2
FAIL: g++.target/i386/pr100637-1w.C  -std=gnu++17  scan-assembler-times pcmpeqw 2
FAIL: g++.target/i386/pr100637-1w.C  -std=gnu++20  scan-assembler-times pcmpeqw 2
FAIL: g++.target/i386/pr100637-1w.C  -std=gnu++98  scan-assembler-times pcmpeqw 2
FAIL: g++.target/i386/pr103861-1.C  -std=gnu++14  scan-assembler-times pcmpeqb 2
FAIL: g++.target/i386/pr103861-1.C  -std=gnu++17  scan-assembler-times pcmpeqb 2
FAIL: g++.target/i386/pr103861-1.C  -std=gnu++20  scan-assembler-times pcmpeqb 2
FAIL: g++.target/i386/pr103861-1.C  -std=gnu++98  scan-assembler-times pcmpeqb 2
FAIL: gcc.target/i386/pr88540.c scan-assembler minpd

gcc/testsuite/ChangeLog:

	PR target/115517
	* g++.target/i386/pr100637-1b.C: Add xfail and -mno-sse4.1.
	* g++.target/i386/pr100637-1w.C: Ditto.
	* g++.target/i386/pr103861-1.C: Ditto.
	* gcc.target/i386/pr88540.c: Ditto.
	* gcc.target/i386/pr103941-2.c: Add -mno-avx512f.
	* g++.target/i386/sse4_1-pr100637-1b.C: New test.
	* g++.target/i386/sse4_1-pr100637-1w.C: New test.
	* g++.target/i386/sse4_1-pr103861-1.C: New test.
	* gcc.target/i386/sse4_1-pr88540.c: New test.
This commit is contained in:
liuhongt 2024-06-19 16:05:58 +08:00
parent 3cb204046c
commit e94e6ee495
9 changed files with 70 additions and 9 deletions

View file

@ -1,6 +1,6 @@
/* PR target/100637 */
/* { dg-do compile } */
/* { dg-options "-O2 -msse2" } */
/* { dg-options "-O2 -msse2 -mno-sse4.1" } */
typedef unsigned char __attribute__((__vector_size__ (4))) __v4qu;
typedef char __attribute__((__vector_size__ (4))) __v4qi;
@ -13,5 +13,5 @@ __v4qu us (__v4qi a, __v4qi b) { return (a > b) ? au : bu; }
__v4qi su (__v4qu a, __v4qu b) { return (a > b) ? as : bs; }
__v4qi ss (__v4qi a, __v4qi b) { return (a > b) ? as : bs; }
/* { dg-final { scan-assembler-times "pcmpeqb" 2 } } */
/* { dg-final { scan-assembler-times "pcmpeqb" 2 { xfail *-*-* } } } */
/* { dg-final { scan-assembler-times "pcmpgtb" 2 } } */

View file

@ -1,6 +1,6 @@
/* PR target/100637 */
/* { dg-do compile } */
/* { dg-options "-O2 -msse2" } */
/* { dg-options "-O2 -msse2 -mno-sse4.1" } */
typedef unsigned short __attribute__((__vector_size__ (4))) __v2hu;
typedef short __attribute__((__vector_size__ (4))) __v2hi;
@ -13,5 +13,5 @@ __v2hu us (__v2hi a, __v2hi b) { return (a > b) ? au : bu; }
__v2hi su (__v2hu a, __v2hu b) { return (a > b) ? as : bs; }
__v2hi ss (__v2hi a, __v2hi b) { return (a > b) ? as : bs; }
/* { dg-final { scan-assembler-times "pcmpeqw" 2 } } */
/* { dg-final { scan-assembler-times "pcmpeqw" 2 { xfail *-*-* } } } */
/* { dg-final { scan-assembler-times "pcmpgtw" 2 } } */

View file

@ -1,6 +1,6 @@
/* PR target/103861 */
/* { dg-do compile } */
/* { dg-options "-O2 -msse2" } */
/* { dg-options "-O2 -msse2 -mno-sse4.1" } */
typedef unsigned char __attribute__((__vector_size__ (2))) __v2qu;
typedef char __attribute__((__vector_size__ (2))) __v2qi;
@ -13,5 +13,5 @@ __v2qu us (__v2qi a, __v2qi b) { return (a > b) ? au : bu; }
__v2qi su (__v2qu a, __v2qu b) { return (a > b) ? as : bs; }
__v2qi ss (__v2qi a, __v2qi b) { return (a > b) ? as : bs; }
/* { dg-final { scan-assembler-times "pcmpeqb" 2 } } */
/* { dg-final { scan-assembler-times "pcmpeqb" 2 { xfail *-*-* } } } */
/* { dg-final { scan-assembler-times "pcmpgtb" 2 } } */

View file

@ -0,0 +1,17 @@
/* PR target/100637 */
/* { dg-do compile } */
/* { dg-options "-O2 -msse4.1" } */
typedef unsigned char __attribute__((__vector_size__ (4))) __v4qu;
typedef char __attribute__((__vector_size__ (4))) __v4qi;
__v4qu au, bu;
__v4qi as, bs;
__v4qu uu (__v4qu a, __v4qu b) { return (a > b) ? au : bu; }
__v4qu us (__v4qi a, __v4qi b) { return (a > b) ? au : bu; }
__v4qi su (__v4qu a, __v4qu b) { return (a > b) ? as : bs; }
__v4qi ss (__v4qi a, __v4qi b) { return (a > b) ? as : bs; }
/* { dg-final { scan-assembler-times "pcmpeqb" 2 } } */
/* { dg-final { scan-assembler-times "pcmpgtb" 2 } } */

View file

@ -0,0 +1,17 @@
/* PR target/100637 */
/* { dg-do compile } */
/* { dg-options "-O2 -msse4.1" } */
typedef unsigned short __attribute__((__vector_size__ (4))) __v2hu;
typedef short __attribute__((__vector_size__ (4))) __v2hi;
__v2hu au, bu;
__v2hi as, bs;
__v2hu uu (__v2hu a, __v2hu b) { return (a > b) ? au : bu; }
__v2hu us (__v2hi a, __v2hi b) { return (a > b) ? au : bu; }
__v2hi su (__v2hu a, __v2hu b) { return (a > b) ? as : bs; }
__v2hi ss (__v2hi a, __v2hi b) { return (a > b) ? as : bs; }
/* { dg-final { scan-assembler-times "pcmpeqw" 2 } } */
/* { dg-final { scan-assembler-times "pcmpgtw" 2 } } */

View file

@ -0,0 +1,17 @@
/* PR target/103861 */
/* { dg-do compile } */
/* { dg-options "-O2 -msse4.1" } */
typedef unsigned char __attribute__((__vector_size__ (2))) __v2qu;
typedef char __attribute__((__vector_size__ (2))) __v2qi;
__v2qu au, bu;
__v2qi as, bs;
__v2qu uu (__v2qu a, __v2qu b) { return (a > b) ? au : bu; }
__v2qu us (__v2qi a, __v2qi b) { return (a > b) ? au : bu; }
__v2qi su (__v2qu a, __v2qu b) { return (a > b) ? as : bs; }
__v2qi ss (__v2qi a, __v2qi b) { return (a > b) ? as : bs; }
/* { dg-final { scan-assembler-times "pcmpeqb" 2 } } */
/* { dg-final { scan-assembler-times "pcmpgtb" 2 } } */

View file

@ -1,5 +1,5 @@
/* { dg-do compile } */
/* { dg-options "-O2 -msse2" } */
/* { dg-options "-O2 -msse2 -mno-avx512f" } */
void foo (int *c, float *x, float *y)
{

View file

@ -1,5 +1,5 @@
/* { dg-do compile } */
/* { dg-options "-O2 -msse2" } */
/* { dg-options "-O2 -msse2 -mno-sse4.1" } */
void test(double* __restrict d1, double* __restrict d2, double* __restrict d3)
{
@ -7,4 +7,4 @@ void test(double* __restrict d1, double* __restrict d2, double* __restrict d3)
d3[n] = d1[n] < d2[n] ? d1[n] : d2[n];
}
/* { dg-final { scan-assembler "minpd" } } */
/* { dg-final { scan-assembler "minpd" { xfail *-*-* } } } */

View file

@ -0,0 +1,10 @@
/* { dg-do compile } */
/* { dg-options "-O2 -msse4.1" } */
void test(double* __restrict d1, double* __restrict d2, double* __restrict d3)
{
for (int n = 0; n < 2; ++n)
d3[n] = d1[n] < d2[n] ? d1[n] : d2[n];
}
/* { dg-final { scan-assembler "minpd" } } */