public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gabravier at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/94824] New: Failure to optimize with __builtin_bswap32 as well as with a function recognized as such
Date: Tue, 28 Apr 2020 15:14:51 +0000 [thread overview]
Message-ID: <bug-94824-4@http.gcc.gnu.org/bugzilla/> (raw)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94824
Bug ID: 94824
Summary: Failure to optimize with __builtin_bswap32 as well as
with a function recognized as such
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: gabravier at gmail dot com
Target Milestone: ---
uint32_t swap32(uint32_t x)
{
return ((x << 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x
>> 24));
}
uint64_t swap64v1(uint64_t x)
{
uint64_t a = __builtin_bswap32(x);
x >>= 32;
a <<= 32;
return __builtin_bswap32(x) | a;
}
uint64_t swap64v2(uint64_t x)
{
uint64_t a = swap32(x);
x >>= 32;
a <<= 32;
return swap32(x) | a;
}
swap64v1 and swap64v2 are identical, since bswap32 is equivalent to
__builtin_bswap32. However, only swap64v2 is optimized to __builtin_bswap64.
swap64v1 is compiled to this by gcc -O3 :
swap64v1(unsigned long):
mov rdx, rdi
mov eax, edi
shr rdx, 32
bswap eax
sal rax, 32
bswap edx
mov edi, edx
or rax, rdi
ret
And swap64v2 gives this :
swap64v2(unsigned long):
mov rax, rdi
bswap rax
ret
next reply other threads:[~2020-04-28 15:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-28 15:14 gabravier at gmail dot com [this message]
2020-04-28 22:48 ` [Bug tree-optimization/94824] " pinskia at gcc dot gnu.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-94824-4@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).