4 ms·
For generalised signed addition, the overhead is 3 instructions per addition. It can be one in specific contexts where more is known about the operands (e.g. ad
by masklinn 5y ago
For generalised signed addition, the overhead is 3 instructions per addition. It can be one in specific contexts where more is known about the operands (e.g. addition of immediates).
It’s always 1 in x64/ARM64 as they have built-in support for overflow.
- Taniwha 5y agoyou have to include the branch instruction too in any comparison
- kccqzy 5y agoIn x86 it is still one instruction: jc or jo after an addition.
- brucehoult 5y agoAnd in RISC-V it's a "BLT sum,summand" after an unsigned addition, and a single branch instruction after a signed addition if you know the sign of one of them e.g. adding or subtracting a constant.
- rurban 5y agobuilt-in support for overflow is not really builtin. There's only adc, but the C library has no such function, and compilers only got them added a few years ago. Almost nobody uses them, as they introduce a dependency. Most workaround that in much slower ways, worse than RISC-V