Re:Branch predictor: How many “if”s are too many?
by bob1029 on Thursday May 06, 2021 @04:18PM
(#27068582)
I might be off base here, but you would probably do best to not overthink this and let the compiler do its job. Attempting to pre-optimize if statements relative to a branch predictor (a very hardware-specific thing) is probably a massive fool's errand.
[ Parent
| on HN ]
Re:Branch predictor: How many “if”s are too many?
by astrange on Thursday May 06, 2021 @06:54PM
(#27069918)
The compiler doesn't know how the CPU branch predictor works either. It's not especially good at optimizing this, or guessing if a branch is predictable or not, so you might as well do it yourself.