svn commit: r229415 - head/lib/libvgl

Dimitry Andric dim at FreeBSD.org
Tue Jan 10 08:02:14 UTC 2012


On 2012-01-10 05:48, Eitan Adler wrote:
> On Mon, Jan 9, 2012 at 11:02 PM, John-Mark Gurney<jmg at funkthat.com>  wrote:
>> Last time I did benchmarking on this ~10 years ago, it was slower to
>> use xor instead of using assignments...
>
> I'd be shocked if the compiler didn't optimize this away to an XCHG.

Even with our ancient gcc 4.2 (on i386):

VGLLine:
	[...]
         movl    12(%ebp), %edx
         movl    16(%ebp), %eax
         movl    $1, -56(%ebp)
         xchgl   %eax, %edx
         movl    %edx, 12(%ebp)
         movl    24(%ebp), %edx
         movl    %eax, 16(%ebp)
         movl    %ecx, %eax
         xchgl   %edx, %esi
         movl    %edx, 24(%ebp)
         movl    -84(%ebp), %edx
         xchgl   %eax, %edx
         movl    %eax, -80(%ebp)
         movl    %edx, -84(%ebp)

With clang, the corresponding local variables seem to have been
optimized away entirely (or rather, moved around).


More information about the svn-src-all mailing list