4 ms·
Because the function doesn't have anywhere to jump to. Instead it generates zero-or-one from the overflow flag (with seto) and the caller will then do something
by gsg 12y ago
Because the function doesn't have anywhere to jump to. Instead it generates zero-or-one from the overflow flag (with seto) and the caller will then do something like test eax, eax/jnz handle_overflow.
In other words, the abstraction boundary introduced by the function call mechanism gets in the way of using the overflow flag directly with jo. Inlining would, presumably, re-expose the opportunity.
- jerven 12y agoThat is another part I missed, the ASM implementation seemed to optimise the function while potentially deoptimising the whole program. For most code overflows are rare, jumping to deal with the rare cases but otherwise just doing the normal is often best for whole program performance. But to be honest I am not current in assembly as I like managed languages to much.