]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Software mitigation: Disable gather generation in vectorization for GDS affected...
authorliuhongt <hongtao.liu@intel.com>
Thu, 10 Aug 2023 03:41:39 +0000 (11:41 +0800)
committerliuhongt <hongtao.liu@intel.com>
Wed, 16 Aug 2023 05:49:48 +0000 (13:49 +0800)
For more details of GDS (Gather Data Sampling), refer to
https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/advisory-guidance/gather-data-sampling.html

After microcode update, there's performance regression. To avoid that,
the patch disables gather generation in autovectorization but uses
gather scalar emulation instead.

gcc/ChangeLog:

* config/i386/i386-options.c (m_GDS): New macro.
* config/i386/x86-tune.def (X86_TUNE_USE_GATHER): Don't enable
for m_GDS.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx2-gather-2.c: Adjust options to keep
gather vectorization.
* gcc.target/i386/avx2-gather-6.c: Ditto.
* gcc.target/i386/avx512f-pr88464-1.c: Ditto.
* gcc.target/i386/avx512f-pr88464-5.c: Ditto.
* gcc.target/i386/avx512vl-pr88464-1.c: Ditto.
* gcc.target/i386/avx512vl-pr88464-11.c: Ditto.
* gcc.target/i386/avx512vl-pr88464-3.c: Ditto.
* gcc.target/i386/avx512vl-pr88464-9.c: Ditto.

(cherry picked from commit 3064d1f5c48cb6ce1b4133570dd08ecca8abb52d)

gcc/config/i386/i386-options.c
gcc/config/i386/x86-tune.def
gcc/testsuite/gcc.target/i386/avx2-gather-2.c
gcc/testsuite/gcc.target/i386/avx2-gather-6.c
gcc/testsuite/gcc.target/i386/avx512f-pr88464-1.c
gcc/testsuite/gcc.target/i386/avx512f-pr88464-5.c
gcc/testsuite/gcc.target/i386/avx512vl-pr88464-1.c
gcc/testsuite/gcc.target/i386/avx512vl-pr88464-11.c
gcc/testsuite/gcc.target/i386/avx512vl-pr88464-3.c
gcc/testsuite/gcc.target/i386/avx512vl-pr88464-9.c

index d47a5433126f7cc67144f5797a78ef9edb7b65c4..e3450345b5a104c6218790207e841ce71b29a9b3 100644 (file)
@@ -137,6 +137,11 @@ along with GCC; see the file COPYING3.  If not see
 #define m_GOLDMONT_PLUS (HOST_WIDE_INT_1U<<PROCESSOR_GOLDMONT_PLUS)
 #define m_TREMONT (HOST_WIDE_INT_1U<<PROCESSOR_TREMONT)
 #define m_INTEL (HOST_WIDE_INT_1U<<PROCESSOR_INTEL)
+/* Gather Data Sampling / CVE-2022-40982 / INTEL-SA-00828.
+   Software mitigation.  */
+#define m_GDS (m_SKYLAKE | m_SKYLAKE_AVX512 | m_CANNONLAKE \
+              | m_ICELAKE_CLIENT | m_ICELAKE_SERVER | m_CASCADELAKE \
+              | m_TIGERLAKE | m_COOPERLAKE | m_ROCKETLAKE)
 
 #define m_GEODE (HOST_WIDE_INT_1U<<PROCESSOR_GEODE)
 #define m_K6 (HOST_WIDE_INT_1U<<PROCESSOR_K6)
index eb057a677508cfa72ad586067a8625fa14603e9b..b390b29843ad77c1d06b4837e971555a9faecb8e 100644 (file)
@@ -442,7 +442,7 @@ DEF_TUNE (X86_TUNE_AVOID_4BYTE_PREFIXES, "avoid_4byte_prefixes",
 
 /* X86_TUNE_USE_GATHER: Use gather instructions.  */
 DEF_TUNE (X86_TUNE_USE_GATHER, "use_gather",
-         ~(m_ZNVER1 | m_ZNVER2 | m_GENERIC))
+         ~(m_ZNVER1 | m_ZNVER2 | m_GENERIC | m_GDS))
 
 /* X86_TUNE_AVOID_128FMA_CHAINS: Avoid creating loops with tight 128bit or
    smaller FMA chain.  */
index 1a704afd834472057efb768a3e76fe980343ea5e..a8bcd0eb3f16addb6b5fe5bcb9ef80ae603e944a 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O3 -mavx2 -fdump-tree-vect-details -mtune=skylake" } */
+/* { dg-options "-O3 -fdump-tree-vect-details -march=skylake -mtune=haswell" } */
 
 #include "avx2-gather-1.c"
 
index b9119581ae2c9c37b613de201ec4de4ac5db06d7..067b251e3936b9cce7ee5a68b56646dd4808797c 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O3 -mavx2 -fno-common -fdump-tree-vect-details -mtune=skylake" } */
+/* { dg-options "-O3 -mavx2 -fno-common -fdump-tree-vect-details  -mtune=haswell" } */
 
 #include "avx2-gather-5.c"
 
index 06d21bb0129904a66c1ae2a30d2cb29b0ec43fa6..d1a2298618ea3a62fb465634433089c602bc3049 100644 (file)
@@ -1,6 +1,6 @@
 /* PR tree-optimization/88464 */
 /* { dg-do compile } */
-/* { dg-options "-O3 -mavx512f -mprefer-vector-width=512 -mtune=skylake-avx512 -fdump-tree-vect-details" } */
+/* { dg-options "-O3 -mavx512f -mprefer-vector-width=512 -mtune=haswell -fdump-tree-vect-details" } */
 /* { dg-final { scan-tree-dump-times "loop vectorized using 64 byte vectors" 4 "vect" } } */
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 4 "vect" } } */
 
index 462e951fdc17754b406477ac93aa7b1f38ec3616..d7b0b2b28cb720b53f7820a15336fc6980db3372 100644 (file)
@@ -1,6 +1,6 @@
 /* PR tree-optimization/88464 */
 /* { dg-do compile } */
-/* { dg-options "-O3 -mavx512f -mprefer-vector-width=512 -mtune=skylake-avx512 -fdump-tree-vect-details" } */
+/* { dg-options "-O3 -mavx512f -mprefer-vector-width=512 -mtune=haswell -fdump-tree-vect-details" } */
 /* { dg-final { scan-tree-dump-times "loop vectorized using 64 byte vectors" 4 "vect" } } */
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 4 "vect" } } */
 
index 55a28dddbf84ff0faf74177f0ab7667789a031a2..07439185ec1720c1bec2e66b3948e2f3bf32ed78 100644 (file)
@@ -1,6 +1,6 @@
 /* PR tree-optimization/88464 */
 /* { dg-do compile } */
-/* { dg-options "-O3 -mavx512vl -mprefer-vector-width=256 -mtune=skylake-avx512 -fdump-tree-vect-details" } */
+/* { dg-options "-O3 -mavx512vl -mprefer-vector-width=256 -mtune=haswell -fdump-tree-vect-details" } */
 /* { dg-final { scan-tree-dump-times "loop vectorized using 32 byte vectors" 4 "vect" } } */
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 4 "vect" } } */
 
index 9696008855da59bcd593555abf7c5603e387019e..3a98108279a4b93c841ef1c1abb2144ebd82e678 100644 (file)
@@ -1,6 +1,6 @@
 /* PR tree-optimization/88464 */
 /* { dg-do compile } */
-/* { dg-options "-O3 -mavx512vl -mprefer-vector-width=128 -mtune=skylake-avx512 -fdump-tree-vect-details" } */
+/* { dg-options "-O3 -mavx512vl -mprefer-vector-width=128 -mtune=haswell -fdump-tree-vect-details" } */
 /* { dg-final { scan-tree-dump-times "loop vectorized using 16 byte vectors" 4 "vect" } } */
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 4 "vect" } } */
 
index 6b0c8a85957f0f8a83453c26552ee41dd54c857b..ac669e0481290f6d1c9e756bfc3275ec6a4049d5 100644 (file)
@@ -1,6 +1,6 @@
 /* PR tree-optimization/88464 */
 /* { dg-do compile } */
-/* { dg-options "-O3 -mavx512vl -mprefer-vector-width=128 -mtune=skylake-avx512 -fdump-tree-vect-details" } */
+/* { dg-options "-O3 -mavx512vl -mprefer-vector-width=128 -mtune=haswell -fdump-tree-vect-details" } */
 /* { dg-final { scan-tree-dump-times "loop vectorized using 16 byte vectors" 4 "vect" } } */
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 4 "vect" } } */
 
index 3af568ab32377e959fb0752691489909d7180b8d..14a1083b6d1115dcbe115af83ce0005526c094f7 100644 (file)
@@ -1,6 +1,6 @@
 /* PR tree-optimization/88464 */
 /* { dg-do compile } */
-/* { dg-options "-O3 -mavx512vl -mprefer-vector-width=256 -mtune=skylake-avx512 -fdump-tree-vect-details" } */
+/* { dg-options "-O3 -mavx512vl -mprefer-vector-width=256 -mtune=haswell -fdump-tree-vect-details" } */
 /* { dg-final { scan-tree-dump-times "loop vectorized using 32 byte vectors" 4 "vect" } } */
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 4 "vect" } } */