This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/67781] [5/6 Regression] wrong code generated on big-endian with -O1 -fexpensive-optimizations
- From: "thopre01 at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 14 Dec 2015 14:09:42 +0000
- Subject: [Bug tree-optimization/67781] [5/6 Regression] wrong code generated on big-endian with -O1 -fexpensive-optimizations
- Auto-submitted: auto-generated
- References: <bug-67781-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67781
--- Comment #7 from Thomas Preud'homme <thopre01 at gcc dot gnu.org> ---
The exact place where it goes wrong is in find_bswap_or_nop (not the _1 helper
function) in the following line:
for (tmpn = n->n, rsize = 0; tmpn; tmpn >>= BITS_PER_MARKER, rsize++);
This code removes the most significant zero on little endian systems but the
least significant one on big endian ones, changing the value in n->n. It should
do some left shift but be careful of undefined behavior.
Actually, this makes me realize that we only remove the most significant zeros
but the least significant ones would be fine too if the base address is
adjusted.