https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77599
Bug ID: 77599
Summary: M68K: __builtin_bswap32() isn't compiled correctly
with -mshort
Product: gcc
Version: 6.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: dhowells at redhat dot com
Target Milestone: ---
The following test code:
unsigned long x(unsigned long y)
{
return __builtin_bswap32(y);
}
is miscompiled for m68k when -mshort is specified. Compiling with
m68k-linux-gnu-gcc -m68000 -S /tmp/3.c -o - -mshort
I see:
x:
link.w %fp,#0
move.l 8(%fp),%d0
ror.w #8,%d0
move.w %d0,%d0
and.l #65535,%d0
unlk %fp
rts
dropping the -mshort I see:
x:
link.w %fp,#0
move.l 8(%fp),%d0
ror.w #8,%d0
swap %d0
ror.w #8,%d0
unlk %fp
rts
I'm using a gcc-6.1.1 cross-compiler built for x86_64, but the problem also
shows up on gcc-5.3.1. The gcc-6.1.1 compiler is svn rev 237634, dated
20160621.