diff options
author | liuhongt <hongtao.liu@intel.com> | 2023-06-26 09:50:25 +0800 |
---|---|---|
committer | liuhongt <hongtao.liu@intel.com> | 2023-06-27 14:13:08 +0800 |
commit | 0b811120b0eb75d6ec01e3d09df9f94f29d7300c (patch) | |
tree | 633ba2345ead6a2851d3ddf0a99e2468e135e125 /gcc | |
parent | a90f558bbb87c0b5d2b1e07d55bd585b2285cf3d (diff) | |
download | gcc-0b811120b0eb75d6ec01e3d09df9f94f29d7300c.zip gcc-0b811120b0eb75d6ec01e3d09df9f94f29d7300c.tar.gz gcc-0b811120b0eb75d6ec01e3d09df9f94f29d7300c.tar.bz2 |
Make option mvzeroupper independent of optimization level.
pass_insert_vzeroupper is under condition
TARGET_AVX && TARGET_VZEROUPPER
&& flag_expensive_optimizations && !optimize_size
But the document of mvzeroupper doesn't mention the insertion
required -O2 and above, it may confuse users when they explicitly
use -Os -mvzeroupper.
------------
mvzeroupper
Target Mask(VZEROUPPER) Save
Generate vzeroupper instruction before a transfer of control flow out of
the function.
------------
The patch moves flag_expensive_optimizations && !optimize_size to
ix86_option_override_internal. It makes -mvzeroupper independent of
optimization level, but still keeps the behavior of architecture
tuning(emit_vzeroupper) unchanged.
gcc/ChangeLog:
* config/i386/i386-features.cc (pass_insert_vzeroupper:gate):
Move flag_expensive_optimizations && !optimize_size to ..
* config/i386/i386-options.cc (ix86_option_override_internal):
.. this, it makes -mvzeroupper independent of optimization
level, but still keeps the behavior of architecture
tuning(emit_vzeroupper) unchanged.
gcc/testsuite/ChangeLog:
* gcc.target/i386/avx-vzeroupper-29.c: New testcase.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/config/i386/i386-features.cc | 3 | ||||
-rw-r--r-- | gcc/config/i386/i386-options.cc | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/avx-vzeroupper-29.c | 14 |
3 files changed, 18 insertions, 3 deletions
diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc index 4a3b07a..92ae08d 100644 --- a/gcc/config/i386/i386-features.cc +++ b/gcc/config/i386/i386-features.cc @@ -2489,8 +2489,7 @@ public: /* opt_pass methods: */ bool gate (function *) final override { - return TARGET_AVX && TARGET_VZEROUPPER - && flag_expensive_optimizations && !optimize_size; + return TARGET_AVX && TARGET_VZEROUPPER; } unsigned int execute (function *) final override diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc index 7f593ce..37cb5a0 100644 --- a/gcc/config/i386/i386-options.cc +++ b/gcc/config/i386/i386-options.cc @@ -2731,7 +2731,9 @@ ix86_option_override_internal (bool main_args_p, sorry ("%<-mcall-ms2sysv-xlogues%> isn%'t currently supported with SEH"); if (!(opts_set->x_target_flags & MASK_VZEROUPPER) - && TARGET_EMIT_VZEROUPPER) + && TARGET_EMIT_VZEROUPPER + && flag_expensive_optimizations + && !optimize_size) opts->x_target_flags |= MASK_VZEROUPPER; if (!(opts_set->x_target_flags & MASK_STV)) opts->x_target_flags |= MASK_STV; diff --git a/gcc/testsuite/gcc.target/i386/avx-vzeroupper-29.c b/gcc/testsuite/gcc.target/i386/avx-vzeroupper-29.c new file mode 100644 index 0000000..4af6377 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx-vzeroupper-29.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -mavx -mtune=generic -mvzeroupper -dp" } */ + +#include <immintrin.h> + +extern __m256 x, y; + +void +foo () +{ + x = y; +} + +/* { dg-final { scan-assembler-times "avx_vzeroupper" 1 } } */ |