re PR target/93089 (Force mprefer-vector-width=512 in 'e' simd clones)
authorJakub Jelinek <jakub@redhat.com>
Fri, 3 Jan 2020 10:14:03 +0000 (11:14 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 3 Jan 2020 10:14:03 +0000 (11:14 +0100)
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.

From-SVN: r279857

gcc/ChangeLog
gcc/config/i386/i386-options.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr93089-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr93089-3.c [new file with mode: 0644]

index c1936a53bb39aaf546a0aaf90aeed3dcf0106a05..8cbaa45d7b315da4726fdab6117c00bda12ea654 100644 (file)
@@ -1,5 +1,11 @@
 2020-01-03  Jakub Jelinek  <jakub@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.
+
        PR target/93089
        * config/i386/i386.opt (x_prefer_vector_width_type): Remove TargetSave
        entry.
index a4c66e4aebf9aef0ec3ebd96aafc6075e109bf0c..2acc9fb0cfedde978ee2e8e7577b073cf7a8def2 100644 (file)
@@ -2950,15 +2950,36 @@ ix86_simd_clone_adjust (struct cgraph_node *node)
        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:
index 48493605dc88c276770f034051cba75cf9c688cf..69f1fbdb8a97b4c8467ab0641f2cfa5bac25b883 100644 (file)
@@ -1,5 +1,9 @@
 2020-01-03  Jakub Jelinek  <jakub@redhat.com>
 
+       PR target/93089
+       * gcc.target/i386/pr93089-2.c: New test.
+       * gcc.target/i386/pr93089-3.c: New test.
+
        PR target/93089
        * gcc.target/i386/pr93089-1.c: New test.
 
diff --git a/gcc/testsuite/gcc.target/i386/pr93089-2.c b/gcc/testsuite/gcc.target/i386/pr93089-2.c
new file mode 100644 (file)
index 0000000..c167dd6
--- /dev/null
@@ -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;
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr93089-3.c b/gcc/testsuite/gcc.target/i386/pr93089-3.c
new file mode 100644 (file)
index 0000000..02f1fae
--- /dev/null
@@ -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;
+}