3 ms·
A few more instruction cycles? Which architecture and which decade?
by lttlrck 13y ago
A few more instruction cycles? Which architecture and which decade?
- ksk 13y agoThis decade :) For modern out-of-order CPUs - xor reg1,reg2 is problematic because the result depends on the previous contents of the register. Hence it cannot be executed out of order. However as a special case xor reg1,reg1 (along with sub reg1,reg1) will be detected by the cpu (intel anyway) as a 'zero idiom' instruction and because it has a smaller opcode than mov reg,0 its preferred. There are also other complex reasons - for detailed info see 3.5.1.8 in the Intel optimization manual.
- Dylan16807 13y ago>This decade :) The initial claim was that mov reg,0 was slower to execute.
- teraflop 13y agoSmaller opcodes will, all else being equal, take up fewer instruction decide cycles and less space in the CPU cache.
- ksk 13y agoA CPU cycle is Fetch,Decode,Execute,Writeback. The 'zero idiom' instructions do not consume any 'Execute' resources. Apart from this.. as the other poster said, smaller opcodes means more instructions can fit inside the caches.