4 ms·
I seem to remember Agner Fog mentioning that the `adc` x86 instruction (add with carry) was considerably slower on many CPUs than `add` (regular addition) becau
by pmjordan 11y ago
I seem to remember Agner Fog mentioning that the `adc` x86 instruction (add with carry) was considerably slower on many CPUs than `add` (regular addition) because it essentially had 3 dependencies (2 operand registers and carry flag), and had to be decomposed into 2 instructions with 2 inputs each for register renaming purposes. Adding 2 64-bit values on x86 is an `add` followed by a dependent `adc`, so that's considerably worse than 2 regular, independent 32-bit additions.
- emn13 11y agoIIRC that limitation was lifted in haswell (the then new fused multiply-add would also otherwise be pointlessly inefficient), though I have no idea about how or whether that affects things like adc.
- pbsd 11y agoIn the case of the carry flag it was only lifted in Broadwell, which also introduced ADCX and ADOX to let you perform two carry chains concurrently. Conditional moves were also improved; you can do 2 per cycle now.
- userbinator 11y agoOn the other hand, the superscalar/OoO means that the dependent instruction doesn't block anything and the CPU will find something else to execute in the meantime, unless everything else is also waiting for it, in which case there's not really anything you can do since a double-width add is two dependent single-width ones.