This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: optimizing predictable branches on x86
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: Kenny Simpson <theonetruekenny at yahoo dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 27 Feb 2008 14:05:41 +0100
- Subject: Re: optimizing predictable branches on x86
- References: <455704.12619.qm@web51509.mail.re2.yahoo.com>
> > At least on x86 it should also be a good idea to know which way
> > the branch is going to go, because it doesn't have explicit branch
> > hints, you really want to be able to optimize the cold branch
> > predictor case if converting from cmov to conditional branches.
>
> x86 as of Pentium 4 does have branch hint instruction prefixes, but their use is somewhat
> discouraged:
>
> from http://softwarecommunity.intel.com/articles/eng/3431.htm:
> "
> The Pentium? 4 Processor introduced new instructions for adding static hints to branches. It is
> not recommended that a programmer use these instructions, as they add slightly to the size of the
> code and are static hints only. It is best to use a conditional branch in the manner that the
> static predictor expects, rather than adding these branch hints.
GCC has support for this feature, but it has turned out to not gain
anything and was disabled by default, since branch reordering stramlines
code well enought to match the default predictor behaviour.
Same conclusion was done by other compiler teams too, ICC is not
generating the hints either.
Honza