Hi! As mentioned in the previous mail, this is what I intend to commit if/when the prefer-vector-width= in target attribute patch makes it in.
Bootstrapped/regtested on x86_64-linux and i686-linux. 2020-01-03 Jakub Jelinek <ja...@redhat.com> PR target/93089 * config/i386/i386-options.c (ix86_simd_clone_adjust): If TARGET_PREFER_AVX128, use prefer-vector-width=256 for 'c' and 'd' simd clones. If TARGET_PREFER_AVX256, use prefer-vector-width=512 for 'e' simd clones. * gcc.target/i386/pr93089-2.c: New test. * gcc.target/i386/pr93089-3.c: New test. --- gcc/config/i386/i386-options.c.jj 2020-01-02 14:00:40.299515822 +0100 +++ gcc/config/i386/i386-options.c 2020-01-02 15:13:00.067579822 +0100 @@ -2950,15 +2950,36 @@ ix86_simd_clone_adjust (struct cgraph_no str = "sse2"; break; case 'c': - if (!TARGET_AVX) + if (TARGET_PREFER_AVX128) + { + if (!TARGET_AVX) + str = "avx,prefer-vector-width=256"; + else + str = "prefer-vector-width=256"; + } + else if (!TARGET_AVX) str = "avx"; break; case 'd': - if (!TARGET_AVX2) + if (TARGET_PREFER_AVX128) + { + if (!TARGET_AVX2) + str = "avx2,prefer-vector-width=256"; + else + str = "prefer-vector-width=256"; + } + else if (!TARGET_AVX2) str = "avx2"; break; case 'e': - if (!TARGET_AVX512F) + if (TARGET_PREFER_AVX256) + { + if (!TARGET_AVX512F) + str = "avx512f,prefer-vector-width=512"; + else + str = "prefer-vector-width=512"; + } + else if (!TARGET_AVX512F) str = "avx512f"; break; default: --- gcc/testsuite/gcc.target/i386/pr93089-2.c.jj 2020-01-02 15:19:01.345119189 +0100 +++ gcc/testsuite/gcc.target/i386/pr93089-2.c 2020-01-02 15:18:34.767520897 +0100 @@ -0,0 +1,12 @@ +/* PR target/93089 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fopenmp-simd -mtune=znver1" } */ +/* { dg-final { scan-assembler "vmulps\[^\n\r]*zmm" } } */ +/* { dg-final { scan-assembler "vmulps\[^\n\r]*ymm" } } */ + +#pragma omp declare simd notinbranch +float +foo (float x, float y) +{ + return x * y; +} --- gcc/testsuite/gcc.target/i386/pr93089-3.c.jj 2020-01-02 15:19:08.460011650 +0100 +++ gcc/testsuite/gcc.target/i386/pr93089-3.c 2020-01-02 15:19:15.734901684 +0100 @@ -0,0 +1,12 @@ +/* PR target/93089 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fopenmp-simd -mtune=skylake-avx512" } */ +/* { dg-final { scan-assembler "vmulps\[^\n\r]*zmm" } } */ +/* { dg-final { scan-assembler "vmulps\[^\n\r]*ymm" } } */ + +#pragma omp declare simd notinbranch +float +foo (float x, float y) +{ + return x * y; +} Jakub