Re:Why is this C++ code faster than my hand-written assembly...
by colejohnson66 on Tuesday August 22, 2017 @01:23PM
(#15074512)
But on x86, division by 2 on an unsigned integer is the same as shifting to the right by 1. So instead of
the OP should've done something like
[ Parent
| on HN ]
Re:Why is this C++ code faster than my hand-written assembly...
by pwdisswordfish on Tuesday August 22, 2017 @05:19PM
(#15076497)
shr rax, 1
div rbx will divide the 128-bit value in (rdx, rax) by rbx, then store the quotient in rax and the remainder in rdx.
Re:Why is this C++ code faster than my hand-written assembly...
by hrydgard on Tuesday August 22, 2017 @01:45PM
(#15074740)
Your second snippet will just zero rdx - don't confuse the registers (rbx is in the mix in the original :)
Re:Why is this C++ code faster than my hand-written assembly...
by colejohnson66 on Tuesday August 22, 2017 @02:26PM
(#15075119)
Thanks :) Fixed.