[Bug target/77599] M68K: __builtin_bswap32() isn't compiled correctly with -mshort

2016-11-17 Thread law at redhat dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77599

Jeffrey A. Law  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 CC||law at redhat dot com
 Resolution|--- |INVALID

--- Comment #2 from Jeffrey A. Law  ---
The problem here is you're using -mshort  on *-linux-gnu which IMHO is invalid.


Linux defines int32_t as a "int".  And -mshort changes the width of an int to
16 bits, at which point anything prototyped using int32_t has just changed its
ABI in a meaningful way (similarly for uint32_t, but unsigned).  You can see
this in the .optimized dump file:

x (long unsigned int y)
{
  unsigned int _1;
  unsigned int _2;
  long unsigned int _4;

;;   basic block 2, loop depth 0, count 0, freq 1, maybe hot
;;prev block 0, next block 1, flags: (NEW, REACHABLE, VISITED)
;;pred:   ENTRY [100.0%]  (FALLTHRU,EXECUTABLE)
  _1 = (unsigned int) y_3(D);
  _2 = __builtin_bswap32 (_1);
  _4 = (long unsigned int) _2;
  return _4;
}

Note the type of the _1 and _2.  They are both unsigned ints, so 16 bits. 


If you try this test on a bare metal target such as m68k-elf or without the
-mshort, you'll get the expected and desired result.

[Bug target/77599] M68K: __builtin_bswap32() isn't compiled correctly with -mshort

2016-09-15 Thread dhowells at redhat dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77599

--- Comment #1 from dhowells at redhat dot com  ---
warthog>m68k-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/m68k-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/m68k-linux-gnu/6.1.1/lto-wrapper
Target: m68k-linux-gnu
Configured with: ../gcc-6.1.1-20160427/configure --bindir=/usr/bin
--build=x86_64-redhat-linux-gnu --datadir=/usr/share --disable-decimal-float
--disable-dependency-tracking --disable-gold --disable-libgcj --disable-libgomp
--disable-libmpx --disable-libquadmath --disable-libssp
--disable-libunwind-exceptions --disable-shared --disable-silent-rules
--disable-sjlj-exceptions --disable-threads
--with-ld=/usr/bin/m68k-linux-gnu-ld --enable-__cxa_atexit
--enable-checking=release --enable-gnu-unique-object --enable-initfini-array
--enable-languages=c,c++ --enable-linker-build-id --enable-lto --enable-nls
--enable-obsolete --enable-plugin --enable-targets=all --exec-prefix=/usr
--host=x86_64-redhat-linux-gnu --includedir=/usr/include
--infodir=/usr/share/info --libexecdir=/usr/libexec --localstatedir=/var
--mandir=/usr/share/man --prefix=/usr --program-prefix=m68k-linux-gnu-
--sbindir=/usr/sbin --sharedstatedir=/var/lib --sysconfdir=/etc
--target=m68k-linux-gnu --with-bugurl=http://bugzilla.redhat.com/bugzilla/
--with-isl --with-newlib --with-plugin-ld=/usr/bin/m68k-linux-gnu-ld
--with-sysroot=/usr/m68k-linux-gnu/sys-root --with-system-libunwind
--with-system-zlib --without-headers --with-linker-hash-style=gnu
Thread model: single
gcc version 6.1.1 20160427 (Red Hat Cross 6.1.1-1) (GCC)