public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/65424] New: gcc does not recognize byte swaps implemented as loop.
@ 2015-03-14 14:31 fuz at fuz dot su
2015-03-18 12:11 ` [Bug tree-optimization/65424] " rguenth at gcc dot gnu.org
2024-02-12 12:20 ` sjames at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: fuz at fuz dot su @ 2015-03-14 14:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65424
Bug ID: 65424
Summary: gcc does not recognize byte swaps implemented as loop.
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: fuz at fuz dot su
Created attachment 35034
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35034&action=edit
endianess-aware reading / writing macros
gcc (r221432) is able to recognize the following code and implements it with
either a bswap or a straight load on x86.
#include <stdint.h>
extern uint32_t
rbe32(const uint8_t a[4])
{
uint32_t x = 0;
x |= a[0] << 24;
x |= a[1] << 16;
x |= a[2] << 8;
x |= a[3] << 0;
return x;
}
extern uint32_t
rle32(const uint8_t a[4])
{
uint32_t x = 0;
x |= a[0] << 0;
x |= a[1] << 8;
x |= a[2] << 16;
x |= a[3] << 24;
return x;
}
it isn't able to recognize the following two functions which yield identical
results:
extern uint32_t
rle32(const uint8_t a[4])
{
int i;
uint32_t x = 0;
for (i = 0; i < 4; i++)
x |= a[i] << 8 * i;
return x;
}
extern uint32_t
rbe32(const uint8_t a[4])
{
int i;
uint32_t x = 0;
for (i = 0; i < 4; i++)
x |= a[i] << 8 * (3 - i);
return x;
}
It would be great if gcc was able to recognize these implementations of
endianess-aware reads; this kind of code is produced by macros I use to
generate a bunch of read / write functions for differently sized types.
Attached is a file containing the macros I want to use.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/65424] gcc does not recognize byte swaps implemented as loop.
2015-03-14 14:31 [Bug tree-optimization/65424] New: gcc does not recognize byte swaps implemented as loop fuz at fuz dot su
@ 2015-03-18 12:11 ` rguenth at gcc dot gnu.org
2024-02-12 12:20 ` sjames at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-03-18 12:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65424
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |missed-optimization
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-03-18
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed. The idea was unrolling would expose it (but we don't unroll these
kind of loops before swap detection).
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/65424] gcc does not recognize byte swaps implemented as loop.
2015-03-14 14:31 [Bug tree-optimization/65424] New: gcc does not recognize byte swaps implemented as loop fuz at fuz dot su
2015-03-18 12:11 ` [Bug tree-optimization/65424] " rguenth at gcc dot gnu.org
@ 2024-02-12 12:20 ` sjames at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-02-12 12:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65424
Sam James <sjames at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sjames at gcc dot gnu.org
--- Comment #6 from Sam James <sjames at gcc dot gnu.org> ---
(In reply to Robert Clausecker from comment #4)
(You can change this in preferences.)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-12 12:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-14 14:31 [Bug tree-optimization/65424] New: gcc does not recognize byte swaps implemented as loop fuz at fuz dot su
2015-03-18 12:11 ` [Bug tree-optimization/65424] " rguenth at gcc dot gnu.org
2024-02-12 12:20 ` sjames 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).