|
|
|
|
|
by saagarjha
1103 days ago
|
|
But there’s inherently more work. You need to keep track of some extra state and when the overflow actually occurs you need to unwind processor state and deliver the exception. You can make this cheap but it definitely cannot be free. From the words you’re using I feel like you have a model in your head that if you can just encode something into an instruction it’s now fast and that instructions are the way we measure how “fast” something is, but that’s not true. Modern processors can retire multiple additions per cycle. What this will probably look like is both of them are single instructions and one of them has a throughput of 4/cycle and the other one will be 3/cycle and compiler authors will pick the former every time. |
|
Then add multiple overflow checking units.
> one of them has a throughput of 4/cycle and the other one will be 3/cycle and compiler authors will pick the former every time.
Currently on RISC-V checked addition requires 4 dependent instructions, so its throughput is about 1 addition/cycle.