Re: Improved Swaping Method In sort.c

From: Andi Kleen
Date: Wed Apr 30 2008 - 14:19:16 EST


Soumyadip Das Mahapatra <dip_kernel@xxxxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/