Re:Web server for Linux written in amd64 assembly
by lttlrck on Monday February 03, 2014 @07:24AM
(#7170261)
A few more instruction cycles? Which architecture and which decade?
[ Parent
| on HN ]
Re:Web server for Linux written in amd64 assembly
by ksk on Monday February 03, 2014 @08:25AM
(#7170471)
This 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.
Re:Web server for Linux written in amd64 assembly
by Dylan16807 on Monday February 03, 2014 @12:14PM
(#7171907)
>This decade :)
The initial claim was that mov reg,0 was slower to execute.
Re:Web server for Linux written in amd64 assembly
by ksk on Monday February 03, 2014 @02:27PM
(#7172885)
A 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.