From: Andi Kleen <andi@firstfloor.org>
To: Jan Hubicka <hubicka@ucw.cz>
Cc: Xinliang David Li <davidxl@google.com>,
GCC Patches <gcc-patches@gcc.gnu.org>,
Teresa Johnson <tejohnson@google.com>
Subject: Re: [PATCH i386]: Enable push/pop in pro/epilogue for modern CPUs
Date: Wed, 12 Dec 2012 18:43:00 -0000 [thread overview]
Message-ID: <m2a9tjdscm.fsf@firstfloor.org> (raw)
In-Reply-To: <m2ehivdslr.fsf@firstfloor.org> (Andi Kleen's message of "Wed, 12 Dec 2012 10:37:36 -0800")
Andi Kleen <andi@firstfloor.org> writes:
>
>>> > /* X86_TUNE_FOUR_JUMP_LIMIT: Some CPU cores are not able to predict more
>>> > than 4 branch instructions in the 16 byte window. */
>>> > - m_PPRO | m_P4_NOCONA | m_CORE2I7 | m_ATOM | m_AMD_MULTIPLE | m_GENERIC,
>>> > + m_PPRO | m_P4_NOCONA | m_ATOM | m_AMD_MULTIPLE | m_GENERIC,
>>
>> This is special passs to handle limitations of AMD's K7/K8/K10 branch prediction.
>> Intel never had similar design, so this flag is pointless.
>
> Actually the Sandy Bridge decoded icache has a limit of 3 jumps per
> 16 byte window.
Actually it's four per 32bytes, sorry.
Here's an old patch I had lying around to optimize for that.
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 1b871be..9b57316 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -2713,6 +2713,7 @@ ix86_target_string (HOST_WIDE_INT isa, int flags, const char *arch,
{ "-mavx256-split-unaligned-load", MASK_AVX256_SPLIT_UNALIGNED_LOAD},
{ "-mavx256-split-unaligned-store", MASK_AVX256_SPLIT_UNALIGNED_STORE},
{ "-mprefer-avx128", MASK_PREFER_AVX128},
+ { "-mjump-pad-32bytes", MASK_JUMP_PAD_32BYTES},
};
const char *opts[ARRAY_SIZE (isa_opts) + ARRAY_SIZE (flag_opts) + 6][2];
@@ -32182,6 +32183,7 @@ ix86_avoid_jump_mispredicts (void)
rtx insn, start = get_insns ();
int nbytes = 0, njumps = 0;
int isjump = 0;
+ int jump_pad_window_size = TARGET_JUMP_PAD_32BYTES ? 32 : 16;
/* Look for all minimal intervals of instructions containing 4 jumps.
The intervals are bounded by START and INSN. NBYTES is the total
@@ -32202,8 +32204,8 @@ ix86_avoid_jump_mispredicts (void)
int align = label_to_alignment (insn);
int max_skip = label_to_max_skip (insn);
- if (max_skip > 15)
- max_skip = 15;
+ if (max_skip > jump_pad_window_size - 1)
+ max_skip = jump_pad_window_size - 1;
/* If align > 3, only up to 16 - max_skip - 1 bytes can be
already in the current 16 byte page, because otherwise
ASM_OUTPUT_MAX_SKIP_ALIGN could skip max_skip or fewer
@@ -32216,7 +32218,7 @@ ix86_avoid_jump_mispredicts (void)
INSN_UID (insn), max_skip);
if (max_skip)
{
- while (nbytes + max_skip >= 16)
+ while (nbytes + max_skip >= jump_pad_window_size)
{
start = NEXT_INSN (start);
if ((JUMP_P (start)
@@ -32262,10 +32264,11 @@ ix86_avoid_jump_mispredicts (void)
fprintf (dump_file, "Interval %i to %i has %i bytes\n",
INSN_UID (start), INSN_UID (insn), nbytes);
- if (njumps == 3 && isjump && nbytes < 16)
+ if (njumps == 3 && isjump && nbytes < jump_pad_window_size)
{
- int padsize = 15 - nbytes + min_insn_size (insn);
-
+ int padsize = jump_pad_window_size - 1 - nbytes +
+ min_insn_size (insn);
+
if (dump_file)
fprintf (dump_file, "Padding insn %i by %i bytes!\n",
INSN_UID (insn), padsize);
diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
index 6c516e7..b38d163 100644
--- a/gcc/config/i386/i386.opt
+++ b/gcc/config/i386/i386.opt
@@ -223,6 +223,10 @@ mintel-syntax
Target Undocumented Alias(masm=, intel, att) Warn(%<-mintel-syntax%> and %<-mno-intel-syntax%> are deprecated; use %<-masm=intel%> and %<-masm=att%> instead)
;; Deprecated
+mjump-pad-32bytes
+Target RejectNegative Mask(JUMP_PAD_32BYTES) Save
+Avoid more than 4 jumps in each 32byte code window.
+
mms-bitfields
Target Report Mask(MS_BITFIELD_LAYOUT) Save
Use native (MS) bitfield layout
--
ak@linux.intel.com -- Speaking for myself only
next prev parent reply other threads:[~2012-12-12 18:43 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-08 18:13 Xinliang David Li
2012-12-12 16:37 ` Jan Hubicka
2012-12-12 17:25 ` Xinliang David Li
2012-12-12 17:34 ` Xinliang David Li
2012-12-12 18:30 ` Jan Hubicka
2012-12-12 18:37 ` Andi Kleen
2012-12-12 18:43 ` Andi Kleen [this message]
2012-12-12 18:43 ` Jan Hubicka
2012-12-12 20:56 ` x86-64 medium memory model Leif Ekblad
2012-12-12 20:59 ` H.J. Lu
2012-12-12 21:33 ` Leif Ekblad
2012-12-13 0:16 ` [PATCH i386]: Enable push/pop in pro/epilogue for modern CPUs Xinliang David Li
2012-12-13 0:16 ` Xinliang David Li
2012-12-13 1:19 ` Jan Hubicka
2012-12-13 6:09 ` Xinliang David Li
2012-12-13 6:21 ` Jakub Jelinek
2012-12-13 7:05 ` Xinliang David Li
2012-12-13 19:28 ` Jan Hubicka
2012-12-13 10:22 ` Richard Biener
2012-12-13 19:43 ` H.J. Lu
2012-12-13 20:26 ` Jan Hubicka
2012-12-13 20:28 ` H.J. Lu
2012-12-13 20:40 ` Jan Hubicka
2012-12-13 21:02 ` H.J. Lu
2012-12-13 21:35 ` Jan Hubicka
2012-12-20 12:13 ` Melik-adamyan, Areg
2012-12-20 14:08 ` H.J. Lu
2012-12-20 15:05 ` Jan Hubicka
2012-12-20 15:07 ` Jan Hubicka
2012-12-20 15:22 ` H.J. Lu
2012-12-21 8:28 ` Zamyatin, Igor
2012-12-09 13:50 Uros Bizjak
2012-12-09 17:09 ` Дмитрий Дьяченко
2012-12-10 9:23 ` Richard Biener
2012-12-10 20:42 ` Xinliang David Li
2012-12-10 21:07 ` Mike Stump
2012-12-11 9:49 ` Richard Biener
2012-12-11 17:15 ` Xinliang David Li
2012-12-11 22:53 Xinliang David Li
2012-12-11 23:39 ` Xinliang David Li
2012-12-12 11:00 ` Richard Biener
2012-12-21 7:26 Xinliang David Li
2012-12-21 8:20 ` Zamyatin, Igor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2a9tjdscm.fsf@firstfloor.org \
--to=andi@firstfloor.org \
--cc=davidxl@google.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@ucw.cz \
--cc=tejohnson@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).