News for hackers. Stuff that matters.
Re:Catching integer overflows in C by bsder on Wednesday August 22, 2018 @01:33AM (#17816545)
> It is crazy how simple x86 assembly language programming makes checking overflow compared to C.

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.

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?
Re:Catching integer overflows in C by abenedic on Wednesday August 22, 2018 @01:46AM (#17816608)
ish, you can use cmov for some stuff.
Re:Catching integer overflows in C by snaky on Wednesday August 22, 2018 @05:46AM (#17817526)
> 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.

https://yarchive.net/comp/linux/cmov.html

Re:Catching integer overflows in C by AstralStorm on Wednesday August 22, 2018 @03:55AM (#17817100)
Where is it available in MIPS?