develooper Front page | perl.perl5.porters | Postings from January 2013

Re: use of LIKELY() and UNLIKELY() branch predictors

Thread Previous | Thread Next
From:
hv
Date:
January 28, 2013 23:24
Subject:
Re: use of LIKELY() and UNLIKELY() branch predictors
Message ID:
201301282219.r0SMJQu13119@crypt.org
Zefram <zefram@fysh.org> wrote:
:Dave Mitchell wrote:
:>1) Has anyone looked at this recently to know whether gcc does anything
:>useful with it?
:
:Yes, it does.  I'm using this facility in a module that I'm currently
:writing, and I perused some of the generated assembly code to see
:whether it makes a difference.  gcc tends to arrange for the unlikely
:case to be taking a branch, while the likely case is to continue inline.
:This is the same thing that I do when writing assembly code manually.
:(amd64, gcc 4.4.5.)

Do you know how this facility plays out in the presence of hardware branch
prediction? The impression I get is that successful hardware prediction 
of a (cacheline-busting) branch is most likely still slower than successful
hardware prediction of a non-branch, so that software hints are still useful;
but I really can't tell for sure from the online resources I've found.

Hugo

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About