This is the mail archive of the gcc@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]

Re: optimizing predictable branches on x86


> > 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


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