This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: PATCH: Use__builtin_bswap[32|64] in i386/x86_64 bits/byteswap.h
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Richard Henderson <rth at twiddle dot net>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Mon, 26 Mar 2012 15:23:31 -0700
- Subject: Re: PATCH: Use__builtin_bswap[32|64] in i386/x86_64 bits/byteswap.h
- References: <CAMe9rOpRv9gDkjN5Kg1580gu7BxmNYtKYd5y6k5DxKm=WK8pFw@mail.gmail.com>
On Mon, Mar 19, 2012 at 10:33 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Sat, Mar 17, 2012 at 10:21 AM, Richard Henderson <rth@twiddle.net> wrote:
>> On 03/17/2012 10:11 AM, H.J. Lu wrote:
>>> GCC 4.7.0 defines __corei7__ for -march=corei7. ?This patch adds
>>> __corei7__ check in i386/x86_64 bits/byteswap.h. ?OK to install?
>>
>> Isn't this (and the last couple added) recent enough that we can just
>> defer to the gcc builtin? ?I.e.
>>
>> #if __GCC_PREREQ(4,2)
>> # define __bswap_16(x) ?__builtin_bswap32((unsigned)(x) << 16)
>> # define __bswap_32(x) ?__builtin_bswap32(x)
>> #else
>> ... rest
>> #endif
>>
>
> Here is a patch to use __builtin_bswap[32|64] in i386/x86_64 bits/byteswap.h
> for GCC >= 4.2. ?I didn't use __builtin_bswap32 for __bswap_16 since it is
> less efficient:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52624
>
> Thanks.
>
>
> --
> H.J.
> --
> 2012-03-19 ?H.J. Lu ?<hongjiu.lu@intel.com>
>
> ? ? ? ?* sysdeps/i386/bits/byteswap.h: Include <features.h>.
> ? ? ? ?(__bswap_32): Use __builtin_bswap32 for GCC >= 4.2.
> ? ? ? ?(__bswap_64): Use __builtin_bswap64 for GCC >= 4.2.
Unfortunately __builtin_bswap32/__builtin_bswap64 don't work with
printf format:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52732
We may need to cast the results explicitly.
--
H.J.