This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Consider repz; ret as jump for branch mispredict padding


Hi!

I've looked today at why test4jmp.sh still shows failures on both x86_64 and
i686 cc1plus binary.  The problem is that ix86_pad_returns creates repz; ret
as normal insns instead of jumps ("return" which it replaces is a jump) and
so ix86_avoid_branch_mispredicts considers it as non-jump.  Fixed thusly,
fixed all test4jmp.sh reported failures in i686 cc1plus and all but one in
x86_64 cc1plus (the remaining one is in .init section, nothing gcc controls
nor anyone cares, because it is executed just once).  .text section in
cc1plus grew by 100-200 bytes.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2009-06-10  Jakub Jelinek  <jakub@redhat.com>

	* config/i386/i386.c (ix86_pad_returns): Use emit_jump_insn_before
	instead of emit_insn_before.

--- gcc/config/i386/i386.c.jj	2009-06-08 11:53:54.000000000 +0200
+++ gcc/config/i386/i386.c	2009-06-10 15:57:53.000000000 +0200
@@ -27756,7 +27756,7 @@ ix86_pad_returns (void)
 	}
       if (replace)
 	{
-	  emit_insn_before (gen_return_internal_long (), ret);
+	  emit_jump_insn_before (gen_return_internal_long (), ret);
 	  delete_insn (ret);
 	}
     }

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]