public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-2115] Make option mvzeroupper independent of optimization level.
@ 2023-06-27  6:13 hongtao Liu
  0 siblings, 0 replies; only message in thread
From: hongtao Liu @ 2023-06-27  6:13 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:0b811120b0eb75d6ec01e3d09df9f94f29d7300c

commit r14-2115-g0b811120b0eb75d6ec01e3d09df9f94f29d7300c
Author: liuhongt <hongtao.liu@intel.com>
Date:   Mon Jun 26 09:50:25 2023 +0800

    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.

Diff:
---
 gcc/config/i386/i386-features.cc                  |  3 +--
 gcc/config/i386/i386-options.cc                   |  4 +++-
 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 4a3b07ae045..92ae08d442e 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 7f593cebe76..37cb5a0dcc4 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 00000000000..4af637757f7
--- /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 } } */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-27  6:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-27  6:13 [gcc r14-2115] Make option mvzeroupper independent of optimization level hongtao Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).