public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/94824] New: Failure to optimize with __builtin_bswap32 as well as with a function recognized as such
@ 2020-04-28 15:14 gabravier at gmail dot com
2020-04-28 22:48 ` [Bug tree-optimization/94824] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: gabravier at gmail dot com @ 2020-04-28 15:14 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug tree-optimization/94824] Failure to optimize with __builtin_bswap32 as well as with a function recognized as such
2020-04-28 15:14 [Bug tree-optimization/94824] New: Failure to optimize with __builtin_bswap32 as well as with a function recognized as such gabravier at gmail dot com
@ 2020-04-28 22:48 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-04-28 22:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94824
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2020-04-28
Status|UNCONFIRMED |NEW
Keywords| |missed-optimization
Severity|normal |enhancement
Ever confirmed|0 |1
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, I have seen this before too.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-28 22:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-28 15:14 [Bug tree-optimization/94824] New: Failure to optimize with __builtin_bswap32 as well as with a function recognized as such gabravier at gmail dot com
2020-04-28 22:48 ` [Bug tree-optimization/94824] " pinskia at gcc dot gnu.org
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).