3 ms·
To add to your last point: look at the optimised assembly and see if your code actually does contain branches. The compiler can see through certain if statement
by mort96 4y ago
To add to your last point: look at the optimised assembly and see if your code actually does contain branches. The compiler can see through certain if statements and replace them with cmov instructions. Replacing that with a complex sequence of arithmetic to get rid of the 'if' might make performance worse rather than better.
- chaboud 4y agoNo rule is strictly true in optimization, except the rule that no rule is strictly true in optimization... It's quite often the case that branches are bad for performance in tight loops, so It's better to treat branches as likely sources of trouble than as no big deal.
- mort96 4y agoI agree. I'm just saying, what is and is not a branch is not obvious.