Re:Catching integer overflows in C
by Mikhail_Edoshin on Wednesday August 22, 2018 @04:10AM
(#17817154)
If the upper bound is known, then we'll just make the check once before the loop, no?
ish, you can use cmov for some stuff.
> cmov's can make a difference. You can use them to avoid polluting your branch prediction tables, you can use them to make code smaller, and you can use them when they simply just fit the problem really well. It's just _not_ the case that they are "obviously better". They simply aren't.
Re:Catching integer overflows in C
by AstralStorm on Wednesday August 22, 2018 @03:55AM
(#17817100)
Where is it available in MIPS?
It's easy to write, but not so easy to optimize the performance.
Overflow checking creates a dependency in between operations and requires the emission of instructions that didn't have to be there before.
i += 1 <branch if overflow> i += 1 <etc>
Means that you are executing more than twice the number of instructions and are getting further behind on the dependency chain each iteration. Eventually, your branch subsystem is completely overwhelmed by a branch that is taken effectively never.