From: Jakub Jelinek Date: Wed, 18 May 2016 09:24:59 +0000 (+0200) Subject: sse.md (pbroadcast_evex_isa): New mode attr. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8ee911651552dc302c766d34a7a73be1dcfcd7a7;p=gcc.git sse.md (pbroadcast_evex_isa): New mode attr. * config/i386/sse.md (pbroadcast_evex_isa): New mode attr. (avx2_pbroadcast): Add another alternative with v instead of x constraints in it, using isa. (avx2_pbroadcast_1): Similarly, add two such alternatives. * gcc.target/i386/avx512bw-vpbroadcast-1.c: New test. * gcc.target/i386/avx512bw-vpbroadcast-2.c: New test. * gcc.target/i386/avx512bw-vpbroadcast-3.c: New test. * gcc.target/i386/avx512vl-vpbroadcast-1.c: New test. * gcc.target/i386/avx512vl-vpbroadcast-2.c: New test. * gcc.target/i386/avx512vl-vpbroadcast-3.c: New test. From-SVN: r236369 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 531ad4d6df1..f3f6d38b9cf 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2016-05-18 Jakub Jelinek + * config/i386/sse.md (pbroadcast_evex_isa): New mode attr. + (avx2_pbroadcast): Add another alternative with v instead + of x constraints in it, using isa. + (avx2_pbroadcast_1): Similarly, add two such alternatives. + * config/i386/sse.md (_palignr): Use constraint x instead of v in second alternative, add avx512bw alternative. diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 27796f4a62a..0bb217dcb35 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -16737,30 +16737,40 @@ (set_attr "btver2_decode" "vector") (set_attr "mode" "OI")]) +(define_mode_attr pbroadcast_evex_isa + [(V64QI "avx512bw") (V32QI "avx512bw") (V16QI "avx512bw") + (V32HI "avx512bw") (V16HI "avx512bw") (V8HI "avx512bw") + (V16SI "avx512f") (V8SI "avx512f") (V4SI "avx512f") + (V8DI "avx512f") (V4DI "avx512f") (V2DI "avx512f")]) + (define_insn "avx2_pbroadcast" - [(set (match_operand:VI 0 "register_operand" "=x") + [(set (match_operand:VI 0 "register_operand" "=x,v") (vec_duplicate:VI (vec_select: - (match_operand: 1 "nonimmediate_operand" "xm") + (match_operand: 1 "nonimmediate_operand" "xm,vm") (parallel [(const_int 0)]))))] "TARGET_AVX2" "vpbroadcast\t{%1, %0|%0, %1}" - [(set_attr "type" "ssemov") + [(set_attr "isa" "*,") + (set_attr "type" "ssemov") (set_attr "prefix_extra" "1") - (set_attr "prefix" "vex") + (set_attr "prefix" "vex,evex") (set_attr "mode" "")]) (define_insn "avx2_pbroadcast_1" - [(set (match_operand:VI_256 0 "register_operand" "=x,x") + [(set (match_operand:VI_256 0 "register_operand" "=x,x,v,v") (vec_duplicate:VI_256 (vec_select: - (match_operand:VI_256 1 "nonimmediate_operand" "m,x") + (match_operand:VI_256 1 "nonimmediate_operand" "m,x,m,v") (parallel [(const_int 0)]))))] "TARGET_AVX2" "@ + vpbroadcast\t{%1, %0|%0, %1} + vpbroadcast\t{%x1, %0|%0, %x1} vpbroadcast\t{%1, %0|%0, %1} vpbroadcast\t{%x1, %0|%0, %x1}" - [(set_attr "type" "ssemov") + [(set_attr "isa" "*,*,,") + (set_attr "type" "ssemov") (set_attr "prefix_extra" "1") (set_attr "prefix" "vex") (set_attr "mode" "")]) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 91c7ebcda1b..3df77a06067 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,12 @@ 2016-05-18 Jakub Jelinek + * gcc.target/i386/avx512bw-vpbroadcast-1.c: New test. + * gcc.target/i386/avx512bw-vpbroadcast-2.c: New test. + * gcc.target/i386/avx512bw-vpbroadcast-3.c: New test. + * gcc.target/i386/avx512vl-vpbroadcast-1.c: New test. + * gcc.target/i386/avx512vl-vpbroadcast-2.c: New test. + * gcc.target/i386/avx512vl-vpbroadcast-3.c: New test. + * gcc.target/i386/avx512vl-vpalignr-3.c: New test. * gcc.target/i386/avx512bw-vpalignr-3.c: New test. diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-vpbroadcast-1.c b/gcc/testsuite/gcc.target/i386/avx512bw-vpbroadcast-1.c new file mode 100644 index 00000000000..da6dba59d95 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512bw-vpbroadcast-1.c @@ -0,0 +1,104 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -mavx512vl -mavx512bw" } */ + +#include + +void +f1 (__m128i x) +{ + register __m128i a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = _mm_broadcastb_epi8 (a); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler "vpbroadcastb\[^\n\r]*xmm16\[^\n\r]*xmm16" } } */ + +void +f2 (__m128i x) +{ + register __m128i a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = _mm_broadcastw_epi16 (a); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler "vpbroadcastw\[^\n\r]*xmm16\[^\n\r]*xmm16" } } */ + +void +f3 (__m128i x) +{ + register __m128i a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = _mm_broadcastd_epi32 (a); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler "vpbroadcastd\[^\n\r]*xmm16\[^\n\r]*xmm16" } } */ + +void +f4 (__m128i x) +{ + register __m128i a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = _mm_broadcastq_epi64 (a); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler "vpbroadcastq\[^\n\r]*xmm16\[^\n\r]*xmm16" } } */ + +void +f5 (__m128i x) +{ + register __m128i a __asm ("xmm16"); + register __m256i b __asm ("xmm17"); + a = x; + asm volatile ("" : "+v" (a)); + b = _mm256_broadcastb_epi8 (a); + asm volatile ("" : "+v" (b)); +} + +/* { dg-final { scan-assembler "vpbroadcastb\[^\n\r]*(xmm1\[67]\[^\n\r]*ymm1\[67]|ymm1\[67]\[^\n\r]*xmm1\[67])" } } */ + +void +f6 (__m128i x) +{ + register __m128i a __asm ("xmm16"); + register __m256i b __asm ("xmm17"); + a = x; + asm volatile ("" : "+v" (a)); + b = _mm256_broadcastw_epi16 (a); + asm volatile ("" : "+v" (b)); +} + +/* { dg-final { scan-assembler "vpbroadcastw\[^\n\r]*(xmm1\[67]\[^\n\r]*ymm1\[67]|ymm1\[67]\[^\n\r]*xmm1\[67])" } } */ + +void +f7 (__m128i x) +{ + register __m128i a __asm ("xmm16"); + register __m256i b __asm ("xmm17"); + a = x; + asm volatile ("" : "+v" (a)); + b = _mm256_broadcastd_epi32 (a); + asm volatile ("" : "+v" (b)); +} + +/* { dg-final { scan-assembler "vpbroadcastd\[^\n\r]*(xmm1\[67]\[^\n\r]*ymm1\[67]|ymm1\[67]\[^\n\r]*xmm1\[67])" } } */ + +void +f8 (__m128i x) +{ + register __m128i a __asm ("xmm16"); + register __m256i b __asm ("xmm17"); + a = x; + asm volatile ("" : "+v" (a)); + b = _mm256_broadcastq_epi64 (a); + asm volatile ("" : "+v" (b)); +} + +/* { dg-final { scan-assembler "vpbroadcastq\[^\n\r]*(xmm1\[67]\[^\n\r]*ymm1\[67]|ymm1\[67]\[^\n\r]*xmm1\[67])" } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-vpbroadcast-2.c b/gcc/testsuite/gcc.target/i386/avx512bw-vpbroadcast-2.c new file mode 100644 index 00000000000..2d623c6edf3 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512bw-vpbroadcast-2.c @@ -0,0 +1,68 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -mavx512vl -mavx512bw" } */ + +typedef char V1 __attribute__((vector_size (16))); +typedef short V2 __attribute__((vector_size (16))); +typedef char V5 __attribute__((vector_size (32))); +typedef short V6 __attribute__((vector_size (32))); +typedef int V7 __attribute__((vector_size (32))); + +void +f1 (V1 x) +{ + register V1 a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = __builtin_shuffle (a, (V1) { 0 }); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler "vpbroadcastb\[^\n\r]*xmm16\[^\n\r]*xmm16" } } */ + +void +f2 (V2 x) +{ + register V2 a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = __builtin_shuffle (a, (V2) { 0 }); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler "vpbroadcastw\[^\n\r]*xmm16\[^\n\r]*xmm16" } } */ + +void +f5 (V5 x) +{ + register V5 a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = __builtin_shuffle (a, (V5) { 0 }); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler "vpbroadcastb\[^\n\r]*(xmm16\[^\n\r]*ymm16|ymm16\[^\n\r]*xmm16)" } } */ + +void +f6 (V6 x) +{ + register V6 a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = __builtin_shuffle (a, (V6) { 0 }); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler "vpbroadcastw\[^\n\r]*(xmm16\[^\n\r]*ymm16|ymm16\[^\n\r]*xmm16)" } } */ + +void +f7 (V7 x) +{ + register V7 a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = __builtin_shuffle (a, (V7) { 0 }); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler "vpbroadcastd\[^\n\r]*(xmm16\[^\n\r]*ymm16|ymm16\[^\n\r]*xmm16)" } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-vpbroadcast-3.c b/gcc/testsuite/gcc.target/i386/avx512bw-vpbroadcast-3.c new file mode 100644 index 00000000000..ff3d27580dd --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512bw-vpbroadcast-3.c @@ -0,0 +1,58 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -mavx512vl -mavx512bw" } */ + +typedef char V1 __attribute__((vector_size (16))); +typedef short V2 __attribute__((vector_size (16))); +typedef char V5 __attribute__((vector_size (32))); +typedef short V6 __attribute__((vector_size (32))); +typedef int V7 __attribute__((vector_size (32))); + +void +f1 (V1 *x) +{ + register V1 a __asm ("xmm16"); + a = __builtin_shuffle (*x, (V1) { 0 }); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler "vpbroadcastb\[^\n\r]*xmm16" } } */ + +void +f2 (V2 *x) +{ + register V2 a __asm ("xmm16"); + a = __builtin_shuffle (*x, (V2) { 0 }); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler "vpbroadcastw\[^\n\r]*xmm16" } } */ + +void +f5 (V5 *x) +{ + register V5 a __asm ("xmm16"); + a = __builtin_shuffle (*x, (V5) { 0 }); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler "vpbroadcastb\[^\n\r]*ymm16" } } */ + +void +f6 (V6 *x) +{ + register V6 a __asm ("xmm16"); + a = __builtin_shuffle (*x, (V6) { 0 }); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler "vpbroadcastw\[^\n\r]*ymm16" } } */ + +void +f7 (V7 *x) +{ + register V7 a __asm ("xmm16"); + a = __builtin_shuffle (*x, (V7) { 0 }); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler "vpbroadcastd\[^\n\r]*ymm16" } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-vpbroadcast-1.c b/gcc/testsuite/gcc.target/i386/avx512vl-vpbroadcast-1.c new file mode 100644 index 00000000000..45458096ba3 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512vl-vpbroadcast-1.c @@ -0,0 +1,104 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -mavx512vl -mno-avx512bw" } */ + +#include + +void +f1 (__m128i x) +{ + register __m128i a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = _mm_broadcastb_epi8 (a); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler-not "vpbroadcastb\[^\n\r]*xmm16" } } */ + +void +f2 (__m128i x) +{ + register __m128i a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = _mm_broadcastw_epi16 (a); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler-not "vpbroadcastw\[^\n\r]*xmm16" } } */ + +void +f3 (__m128i x) +{ + register __m128i a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = _mm_broadcastd_epi32 (a); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler "vpbroadcastd\[^\n\r]*xmm16\[^\n\r]*xmm16" } } */ + +void +f4 (__m128i x) +{ + register __m128i a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = _mm_broadcastq_epi64 (a); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler "vpbroadcastq\[^\n\r]*xmm16\[^\n\r]*xmm16" } } */ + +void +f5 (__m128i x) +{ + register __m128i a __asm ("xmm16"); + register __m256i b __asm ("xmm17"); + a = x; + asm volatile ("" : "+v" (a)); + b = _mm256_broadcastb_epi8 (a); + asm volatile ("" : "+v" (b)); +} + +/* { dg-final { scan-assembler-not "vpbroadcastb\[^\n\r]*\[xy]mm1\[67]" } } */ + +void +f6 (__m128i x) +{ + register __m128i a __asm ("xmm16"); + register __m256i b __asm ("xmm17"); + a = x; + asm volatile ("" : "+v" (a)); + b = _mm256_broadcastw_epi16 (a); + asm volatile ("" : "+v" (b)); +} + +/* { dg-final { scan-assembler-not "vpbroadcastw\[^\n\r]*\[xy]mm1\[67]" } } */ + +void +f7 (__m128i x) +{ + register __m128i a __asm ("xmm16"); + register __m256i b __asm ("xmm17"); + a = x; + asm volatile ("" : "+v" (a)); + b = _mm256_broadcastd_epi32 (a); + asm volatile ("" : "+v" (b)); +} + +/* { dg-final { scan-assembler "vpbroadcastd\[^\n\r]*(xmm1\[67]\[^\n\r]*ymm1\[67]|ymm1\[67]\[^\n\r]*xmm1\[67])" } } */ + +void +f8 (__m128i x) +{ + register __m128i a __asm ("xmm16"); + register __m256i b __asm ("xmm17"); + a = x; + asm volatile ("" : "+v" (a)); + b = _mm256_broadcastq_epi64 (a); + asm volatile ("" : "+v" (b)); +} + +/* { dg-final { scan-assembler "vpbroadcastq\[^\n\r]*(xmm1\[67]\[^\n\r]*ymm1\[67]|ymm1\[67]\[^\n\r]*xmm1\[67])" } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-vpbroadcast-2.c b/gcc/testsuite/gcc.target/i386/avx512vl-vpbroadcast-2.c new file mode 100644 index 00000000000..aed9914b597 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512vl-vpbroadcast-2.c @@ -0,0 +1,68 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -mavx512vl -mno-avx512bw" } */ + +typedef char V1 __attribute__((vector_size (16))); +typedef short V2 __attribute__((vector_size (16))); +typedef char V5 __attribute__((vector_size (32))); +typedef short V6 __attribute__((vector_size (32))); +typedef int V7 __attribute__((vector_size (32))); + +void +f1 (V1 x) +{ + register V1 a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = __builtin_shuffle (a, (V1) { 0 }); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler-not "vpbroadcastb\[^\n\r]*xmm16" } } */ + +void +f2 (V2 x) +{ + register V2 a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = __builtin_shuffle (a, (V2) { 0 }); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler-not "vpbroadcastw\[^\n\r]*xmm16" } } */ + +void +f5 (V5 x) +{ + register V5 a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = __builtin_shuffle (a, (V5) { 0 }); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler-not "vpbroadcastb\[^\n\r]*\[xy]mm16" } } */ + +void +f6 (V6 x) +{ + register V6 a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = __builtin_shuffle (a, (V6) { 0 }); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler-not "vpbroadcastw\[^\n\r]*\[xy]mm16" } } */ + +void +f7 (V7 x) +{ + register V7 a __asm ("xmm16"); + a = x; + asm volatile ("" : "+v" (a)); + a = __builtin_shuffle (a, (V7) { 0 }); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler "vpbroadcastd\[^\n\r]*(xmm16\[^\n\r]*ymm16|ymm16\[^\n\r]*xmm16)" } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-vpbroadcast-3.c b/gcc/testsuite/gcc.target/i386/avx512vl-vpbroadcast-3.c new file mode 100644 index 00000000000..b93bd362ed3 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512vl-vpbroadcast-3.c @@ -0,0 +1,58 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -mavx512vl -mno-avx512bw" } */ + +typedef char V1 __attribute__((vector_size (16))); +typedef short V2 __attribute__((vector_size (16))); +typedef char V5 __attribute__((vector_size (32))); +typedef short V6 __attribute__((vector_size (32))); +typedef int V7 __attribute__((vector_size (32))); + +void +f1 (V1 *x) +{ + register V1 a __asm ("xmm16"); + a = __builtin_shuffle (*x, (V1) { 0 }); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler-not "vpbroadcastb\[^\n\r]*xmm16" } } */ + +void +f2 (V2 *x) +{ + register V2 a __asm ("xmm16"); + a = __builtin_shuffle (*x, (V2) { 0 }); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler-not "vpbroadcastw\[^\n\r]*xmm16" } } */ + +void +f5 (V5 *x) +{ + register V5 a __asm ("xmm16"); + a = __builtin_shuffle (*x, (V5) { 0 }); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler-not "vpbroadcastb\[^\n\r]*ymm16" } } */ + +void +f6 (V6 *x) +{ + register V6 a __asm ("xmm16"); + a = __builtin_shuffle (*x, (V6) { 0 }); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler-not "vpbroadcastw\[^\n\r]*ymm16" } } */ + +void +f7 (V7 *x) +{ + register V7 a __asm ("xmm16"); + a = __builtin_shuffle (*x, (V7) { 0 }); + asm volatile ("" : "+v" (a)); +} + +/* { dg-final { scan-assembler "vpbroadcastd\[^\n\r]*ymm16" } } */