Messages in this thread | | | Subject | Re: Improved Swaping Method In sort.c | From | Andi Kleen <> | Date | Wed, 30 Apr 2008 20:17:22 +0200 |
| |
Soumyadip Das Mahapatra <dip_kernel@yahoo.co.in> writes:
> But this code saves memory equaling two integers. What about that ?
It won't because the compiler uses registers not memory for the temporary of course. In fact your version will cause more memory accesses because the compiler doesn't know that a and b do not alias each other, so it cannot cache the immediate value and has to always go through memory. The difference will not be large on x86 because L1 cache accesses are reasonably fast, but they're still much slower than a register access.
-Andi
| |