Split notl + pbraodcast + pand to pbroadcast + pandn more modes.

r12-5595-gc39d77f252e895306ef88c1efb3eff04e4232554 adds 2 splitter to
transform notl + pbroadcast + pand to pbroadcast + pandn for
VI124_AVX2 which leaves out all DI-element-size ones as
well as all 512-bit ones.
This patch extend the splitter to VI_AVX2 which will handle DImode for
AVX2, and V64QImode,V32HImode,V16SImode,V8DImode for AVX512.

gcc/ChangeLog:

	PR target/100711
	* config/i386/sse.md (*andnot<mode>3): Extend below splitter
	to VI_AVX2 to cover more modes.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr100711-2.c: Add v4di/v2di testcases.
	* gcc.target/i386/pr100711-3.c: New test.
This commit is contained in:
liuhongt 2023-05-25 16:14:14 +08:00
parent cc6eb8b51f
commit ed6a9a3579
3 changed files with 59 additions and 7 deletions

View file

@ -17116,17 +17116,17 @@
;; PR target/100711: Split notl; vpbroadcastd; vpand as vpbroadcastd; vpandn
(define_split
[(set (match_operand:VI124_AVX2 0 "register_operand")
(and:VI124_AVX2
(vec_duplicate:VI124_AVX2
[(set (match_operand:VI_AVX2 0 "register_operand")
(and:VI_AVX2
(vec_duplicate:VI_AVX2
(not:<ssescalarmode>
(match_operand:<ssescalarmode> 1 "register_operand")))
(match_operand:VI124_AVX2 2 "vector_operand")))]
(match_operand:VI_AVX2 2 "vector_operand")))]
"TARGET_AVX2"
[(set (match_dup 3)
(vec_duplicate:VI124_AVX2 (match_dup 1)))
(vec_duplicate:VI_AVX2 (match_dup 1)))
(set (match_dup 0)
(and:VI124_AVX2 (not:VI124_AVX2 (match_dup 3))
(and:VI_AVX2 (not:VI_AVX2 (match_dup 3))
(match_dup 2)))]
"operands[3] = gen_reg_rtx (<MODE>mode);")

View file

@ -4,10 +4,12 @@
typedef char v16qi __attribute__ ((vector_size (16)));
typedef short v8hi __attribute__ ((vector_size (16)));
typedef int v4si __attribute__ ((vector_size (16)));
typedef long long v2di __attribute__((vector_size (16)));
typedef char v32qi __attribute__ ((vector_size (32)));
typedef short v16hi __attribute__ ((vector_size (32)));
typedef int v8si __attribute__ ((vector_size (32)));
typedef long long v4di __attribute__((vector_size (32)));
v16qi foo_v16qi (char a, v16qi b)
{
@ -25,6 +27,11 @@ v4si foo_v4si (int a, v4si b)
return (__extension__ (v4si) {~a, ~a, ~a, ~a}) & b;
}
v2di foo_v2di (long long a, v2di b)
{
return (__extension__ (v2di) {~a, ~a}) & b;
}
v32qi foo_v32qi (char a, v32qi b)
{
return (__extension__ (v32qi) {~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a,
@ -44,4 +51,9 @@ v8si foo_v8si (int a, v8si b)
return (__extension__ (v8si) {~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a,}) & b;
}
/* { dg-final { scan-assembler-times "vpandn" 6 } } */
v4di foo_v4di (long long a, v4di b)
{
return (__extension__ (v4di) {~a, ~a, ~a, ~a}) & b;
}
/* { dg-final { scan-assembler-times "vpandn" 8 } } */

View file

@ -0,0 +1,40 @@
/* { dg-do compile } */
/* { dg-options "-O2 -mavx512bw" } */
typedef char v64qi __attribute__ ((vector_size (64)));
typedef short v32hi __attribute__ ((vector_size (64)));
typedef int v16si __attribute__ ((vector_size (64)));
typedef long long v8di __attribute__((vector_size (64)));
v64qi foo_v64qi (char a, v64qi b)
{
return (__extension__ (v64qi) {~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a,
~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a,
~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a,
~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a,
~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a,
~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a,
~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a,
~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a}) & b;
}
v32hi foo_v32hi (short a, v32hi b)
{
return (__extension__ (v32hi) {~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a,
~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a,
~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a,
~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a}) & b;
}
v16si foo_v16si (int a, v16si b)
{
return (__extension__ (v16si) {~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a,
~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a}) & b;
}
v8di foo_v8di (long long a, v8di b)
{
return (__extension__ (v8di) {~a, ~a, ~a, ~a, ~a, ~a, ~a, ~a}) & b;
}
/* { dg-final { scan-assembler-times "vpandn" 4 } } */