Date: Tue, 10 Jan 2012 09:02:11 +0100 From: Dimitry Andric <dim@FreeBSD.org> To: Eitan Adler <lists@eitanadler.com> Cc: svn-src-head@freebsd.org, John-Mark Gurney <jmg@funkthat.com>, "Pedro F. Giffuni" <pfg@freebsd.org>, src-committers@freebsd.org, svn-src-all@freebsd.org Subject: Re: svn commit: r229415 - head/lib/libvgl Message-ID: <4F0BF083.90003@FreeBSD.org> In-Reply-To: <CAF6rxg=2BKy-_z_hRpX25U4dXhemha49gbajmvERmtkyBNH%2BYw@mail.gmail.com> References: <201201031947.q03JlXnx039684@svn.freebsd.org> <20120110040219.GE52468@funkthat.com> <CAF6rxg=2BKy-_z_hRpX25U4dXhemha49gbajmvERmtkyBNH%2BYw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2012-01-10 05:48, Eitan Adler wrote:
> On Mon, Jan 9, 2012 at 11:02 PM, John-Mark Gurney<jmg@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).
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4F0BF083.90003>
