Re: branch guessing, Microarchitectural support for counting

Liste des GroupesRevenir à c arch 
Sujet : Re: branch guessing, Microarchitectural support for counting
De : tkoenig (at) *nospam* netcologne.de (Thomas Koenig)
Groupes : comp.arch
Date : 26. Dec 2024, 23:27:51
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vkkl97$35sr8$1@dont-email.me>
References : 1 2 3 4 5
User-Agent : slrn/1.0.3 (Linux)
John Levine <johnl@taugh.com> schrieb:
According to Michael S  <already5chosen@yahoo.com>:
Yes, compilers often generate such code.
When coding in asm, I typically know at least something about
probability of branches, so I tend to code it differently:
>
The first version of FORTRAN had a FREQUENCY statement which let you tell it the
relative likelihood of each of the results of a three-way IF, and the expected number of
iterations of a DO loop.  It turned out to be useless, because programmers usually
guessed wrong.
>
The final straw was a compiler where they realized FREQUENCY was implemented
backward and nobody noticed.
>
Unless you've profiled the code and you data to support your branch guesses,
just write it in the clearest way you can.

There is one partial expeption: Putting error handling, which
should occur very infrequently, in a cold partition can indeed
bring benefits, and the compiler can not always figure it out;
heuristics like "a NULL check is less likely to be taken" can
be wrong.

But then again, defining an "unlikely" macro and having code like

    if (unlikely (a>b))
      {
         /* Do some error handling.  */        
      }

probably increases the readability over the naked condition, so...

Date Sujet#  Auteur
3 Oct 24 * Microarchitectural support for counting33Anton Ertl
3 Oct 24 +* Re: Microarchitectural support for counting28Brett
5 Oct 24 i`* Re: Microarchitectural support for counting27MitchAlsup1
5 Oct 24 i +- Re: Microarchitectural support for counting1Brett
5 Oct 24 i +* Interrupts in OoO (was: Microarchitectural support for counting)7Anton Ertl
7 Oct 24 i i+* Re: Interrupts in OoO (was: Microarchitectural support for counting)4Brett
7 Oct 24 i ii+* Re: Interrupts in OoO2MitchAlsup1
8 Oct 24 i iii`- Re: Interrupts in OoO1MitchAlsup1
8 Oct 24 i ii`- Re: Interrupts in OoO1Terje Mathisen
7 Oct 24 i i+- Re: Interrupts in OoO1MitchAlsup1
13 Oct 24 i i`- Re: Interrupts in OoO1Anton Ertl
5 Oct 24 i +* Re: Microarchitectural support for counting2MitchAlsup1
25 Dec 24 i i`- Re: Microarchitectural support for counting1MitchAlsup1
25 Dec 24 i +* Re: Microarchitectural support for counting8Paul A. Clayton
25 Dec 24 i i`* Re: Microarchitectural support for counting7MitchAlsup1
25 Dec 24 i i +- Re: Microarchitectural support for counting1MitchAlsup1
31 Dec 24 i i `* Re: Microarchitectural support for counting5Paul A. Clayton
1 Jan 25 i i  `* Re: Microarchitectural support for counting4MitchAlsup1
2 Jan 25 i i   +- Re: Microarchitectural support for counting1MitchAlsup1
6 Jan 25 i i   `* Re: Microarchitectural support for counting2Paul A. Clayton
7 Jan 25 i i    `- Re: Microarchitectural support for counting1Terje Mathisen
25 Dec 24 i `* Re: Microarchitectural support for counting8MitchAlsup1
26 Dec 24 i  +* Dealing with mispredictions (was: Microarchitectural support ...)2Anton Ertl
26 Dec 24 i  i`- Re: Dealing with mispredictions1MitchAlsup1
26 Dec 24 i  `* Re: Microarchitectural support for counting5Michael S
26 Dec 24 i   `* Re: branch guessing, Microarchitectural support for counting4John Levine
26 Dec 24 i    +- Re: branch guessing, Microarchitectural support for counting1Michael S
26 Dec 24 i    +- Re: branch guessing, Microarchitectural support for counting1MitchAlsup1
26 Dec 24 i    `- Re: branch guessing, Microarchitectural support for counting1Thomas Koenig
26 Dec 24 +* Re: Microarchitectural support for counting2Chris M. Thomasson
26 Dec 24 i`- Re: Microarchitectural support for counting1Anton Ertl
27 Dec 24 `* Re: Microarchitectural support for counting2jseigh
28 Dec 24  `- Re: Microarchitectural support for counting1jseigh

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal