Re:Fastest sort of fixed length 6 int array
by skimbrel on Wednesday August 24, 2011 @08:47AM
(#2920470)
Wow, thanks for the link. I'd never heard of sorting networks before. The first thing I thought of was "use an XOR swap to cut memory accesses"...
[ Parent
| on HN ]
Re:Fastest sort of fixed length 6 int array
by rpearl on Wednesday August 24, 2011 @11:17AM
(#2921019)
If you do the naive implementation:
int temp = x;
x = y;
y = temp;
Then a sufficiently smart compiler can decide to assign, say, %eax to x and %ebx to y, and then just rename its notion of registers, and after the swap just begin using %ebx for x and %eax for y. A swap with no copies at all!
(It won't do this in every case, and it depends on context, but such an optimization is possible... but not with xor swaps.)
At least xor swaps would need an even smarter compiler.
Re:Fastest sort of fixed length 6 int array
by onemoreact on Wednesday August 24, 2011 @10:00AM
(#2920688)
I don't think that optimization helps when you have a spare register to use as a temp value.