[Bug c/95661] New: Code built with -m32 uses SSE2 instructions
memmerto at ca dot ibm.com
gcc-bugzilla@gcc.gnu.org
Sat Jun 13 01:24:48 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95661
Bug ID: 95661
Summary: Code built with -m32 uses SSE2 instructions
Product: gcc
Version: 8.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: memmerto at ca dot ibm.com
Target Milestone: ---
When building 32-bit code with -m32, SSE2 instructions are generated. This is
in contrast to the docs.
https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
"The -m32 option sets int, long, and pointer types to 32 bits, and generates
code that runs on any i386 system."
In particular, the code to do floating-point/integer conversions appear to use
SSE2 instructions.
Compiler:
$ /opt/rh/devtoolset-8/root/usr/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/opt/rh/devtoolset-8/root/usr/bin/gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-8/root/usr
--mandir=/opt/rh/devtoolset-8/root/usr/share/man
--infodir=/opt/rh/devtoolset-8/root/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --with-linker-hash-style=gnu
--with-default-libstdcxx-abi=gcc4-compatible --enable-plugin
--enable-initfini-array
--with-isl=/builddir/build/BUILD/gcc-8.3.1-20190311/obj-x86_64-redhat-linux/isl-install
--disable-libmpx --enable-gnu-indirect-function --with-tune=generic
--with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 8.3.1 20190311 (Red Hat 8.3.1-3) (GCC)
Compile Command:
gcc -c -m32 t.c -save-temps -fverbose-asm -o t.o
Testcase:
#include <stdio.h>
#include <float.h>
int main(void)
{
double d = 100.0;
int i = (int)d;
printf("%d\n",i);
}
Assembly Fragment:
# t.c:7: int i = (int)d;
movsd -16(%ebp), %xmm0 # d, tmp90
cvttsd2si %xmm0, %eax # tmp90, tmp91
movl %eax, -20(%ebp) # tmp91, i
I would expect 387 instructions to be generated (since -mfpmath is the default
for 32-bit targets).
More information about the Gcc-bugs
mailing list