diff mbox

Emit vzeroupper even from gen_return and gen_simple_return

Message ID 20111111153343.GV27242@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Nov. 11, 2011, 3:33 p.m. UTC
Hi!

The avx-vzeroupper-14.c testcase now fails, because normal epilogue isn't
emitted and before simple_return or return we forgot to emit the vzeroupper
insn.  Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk?

2011-11-11  Jakub Jelinek  <jakub@redhat.com>

	* config/i386/i386-protos.h (ix86_maybe_emit_epilogue_vzeroupper):
	New prototype.
	* config/i386/i386.c (ix86_maybe_emit_epilogue_vzeroupper): New
	function.
	(ix86_expand_epilogue): Use it.
	* config/i386/i386.md (return, simple_return): Call it in the
	expanders.


	Jakub

Comments

Uros Bizjak Nov. 11, 2011, 3:46 p.m. UTC | #1
On Fri, Nov 11, 2011 at 4:33 PM, Jakub Jelinek <jakub@redhat.com> wrote:

> The avx-vzeroupper-14.c testcase now fails, because normal epilogue isn't
> emitted and before simple_return or return we forgot to emit the vzeroupper
> insn.  Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
> ok for trunk?

OK.

Thanks,
Uros.
diff mbox

Patch

--- gcc/config/i386/i386-protos.h.jj	2011-11-07 12:40:55.000000000 +0100
+++ gcc/config/i386/i386-protos.h	2011-11-11 13:39:48.322746212 +0100
@@ -32,6 +32,7 @@  extern void ix86_setup_frame_addresses (
 
 extern HOST_WIDE_INT ix86_initial_elimination_offset (int, int);
 extern void ix86_expand_prologue (void);
+extern void ix86_maybe_emit_epilogue_vzeroupper (void);
 extern void ix86_expand_epilogue (int);
 extern void ix86_expand_split_stack_prologue (void);
 
--- gcc/config/i386/i386.c.jj	2011-11-10 18:09:12.000000000 +0100
+++ gcc/config/i386/i386.c	2011-11-11 13:39:22.375900662 +0100
@@ -10614,6 +10614,17 @@  ix86_emit_restore_sse_regs_using_mov (HO
       }
 }
 
+/* Emit vzeroupper if needed.  */
+
+void
+ix86_maybe_emit_epilogue_vzeroupper (void)
+{
+  if (TARGET_VZEROUPPER
+      && !TREE_THIS_VOLATILE (cfun->decl)
+      && !cfun->machine->caller_return_avx256_p)
+    emit_insn (gen_avx_vzeroupper (GEN_INT (call_no_avx256)));
+}
+
 /* Restore function stack, frame, and registers.  */
 
 void
@@ -10911,10 +10922,7 @@  ix86_expand_epilogue (int style)
     }
 
   /* Emit vzeroupper if needed.  */
-  if (TARGET_VZEROUPPER
-      && !TREE_THIS_VOLATILE (cfun->decl)
-      && !cfun->machine->caller_return_avx256_p)
-    emit_insn (gen_avx_vzeroupper (GEN_INT (call_no_avx256)));
+  ix86_maybe_emit_epilogue_vzeroupper ();
 
   if (crtl->args.pops_args && crtl->args.size)
     {
--- gcc/config/i386/i386.md.jj	2011-11-08 09:27:01.000000000 +0100
+++ gcc/config/i386/i386.md	2011-11-11 13:40:41.081432858 +0100
@@ -11736,6 +11736,7 @@  (define_expand "return"
   [(simple_return)]
   "ix86_can_use_return_insn_p ()"
 {
+  ix86_maybe_emit_epilogue_vzeroupper ();
   if (crtl->args.pops_args)
     {
       rtx popc = GEN_INT (crtl->args.pops_args);
@@ -11752,6 +11753,7 @@  (define_expand "simple_return"
   [(simple_return)]
   "!TARGET_SEH"
 {
+  ix86_maybe_emit_epilogue_vzeroupper ();
   if (crtl->args.pops_args)
     {
       rtx popc = GEN_INT (crtl->args.pops_args);