swap (a, b) - test

Andi Kleen ak@muc.de
Mon Jan 5 04:08:00 GMT 1998


Eric Buddington <eric@sparrow.vgernet.net> writes:

> On Sat, Jan 03, 1998 at 08:12:51PM -0800, Richard Henderson wrote:
> 
> > If it is faster at all I'll warrent it is only so for depressingly
> > register starved machines.
> 
> Well, I'm on an Intel 486 - that probably qualifies.
> 
> Now, I *did* get great advantage from this before, in more complex
> code (quicksort), under gcc-2.7.2.3.
> 
> However, a quick test now is now running slower with the XOR swap. I
> don't see why three XOR operations on two ints would be slower
> than three assignments among three ints...

__asm__("xchg %1,%0" ...); might be faster on x86 too.

-Andi



More information about the Gcc mailing list