4 ms·
> A useful near-term feature would be zero-cost hardware exceptions on integer overflow. I see this mentioned regularly. Has anybody actually measured that per
by acqq 10y ago
> A useful near-term feature would be zero-cost hardware exceptions on integer overflow.
I see this mentioned regularly. Has anybody actually measured that performance penalty? I'd really like to see the benchmarks and the code samples (both the high-level and the machine code). Because at the machine code level it's just checking a single flag after the operation that could have resulted in an overflow, and only if there's an overflow more exception code has to be executed. And nobody should program the execution paths where the exceptions happen much more often than not? If there's a need for an explicit check (like when implementing bignum routines) there should be a real language feature for that, that is, something the language designers should do, not the CPU designers.
- fulafel 10y agoThe Rust people did, it then became a discussion about sufficiently smart compilers. I'd imagine from a compiler engineering standpoint, it't pretty hard to make this performance neutral. It makes all the artichmetic loops into non-leaf nodes in the call graph and so has second order effects in optimization passes.
- hinkley 10y agoIf your parameters have known ranges you could elide a lot of checks. You're not going to overflow multiplying an 8 bit number times a 16 bit number, for instance.