This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/16584] New: -msse2 also enabling -mfpmath=sse option causing illegal instruction errors
- From: "aron-gcc at sightspeed dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Jul 2004 02:46:59 -0000
- Subject: [Bug c/16584] New: -msse2 also enabling -mfpmath=sse option causing illegal instruction errors
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The gcc command line option -msse2 seems to be implicitly turning on the -
mfpmath=sse option. The man pages describe the -msse2 as only enabling the use
of SSE2 intrinsics rather than automatic use.
This bug is very dangorous since it breaks using runtime detection of SSE2
support. We use the -msse2 option to only generate SSE2 code in areas where we
have written intrinsics so that a single binary is platform safe.
A simple example is:
gcc -msse2 test.c
<file test.c>
int main(void)
{
int i = 1;
float temp2 = 1.0 * (i*i); // Allow for an optimal sse2 int to float
conversion
return 0;
}
<test.s> output
.file "test.c"
.text
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
subl $24, %esp
andl $-16, %esp
movl $0, %eax
addl $15, %eax
addl $15, %eax
shrl $4, %eax
sall $4, %eax
subl %eax, %esp
movl $1, -4(%ebp)
movl -4(%ebp), %eax
imull -4(%ebp), %eax
cvtsi2sd %eax, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -8(%ebp)
movl $0, %eax
leave
ret
.size main, .-main
.section .note.GNU-stack,"",@progbits
.ident "GCC: (GNU) 3.4.0"
<end>
Note that the movss, cvtsi2sd and cvtsd2ss instructions are used which should
not happen.
When this is compiled and run on a Pentium 3 machine a SIGILL is generated.
<Additional Information>
<file test.i>
# 1 "test.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "test.c"
int main(void)
{
int i = 1;
float temp2 = 1.0 * (i*i);
return 0;
}
<end file>
Reading specs from /usr/lib/gcc/i486-slackware-linux/3.4.0/specs
Configured with: ../gcc-3.4.0/configure --prefix=/usr --enable-shared --enable-
threads=posix --enable-__cxa_atexit --disable-checking --with-gnu-ld --verbose -
-target=i486-slackware-linux --host=i486-slackware-linux
Thread model: posix
gcc version 3.4.0
/usr/libexec/gcc/i486-slackware-linux/3.4.0/cc1 -E -quiet -v test.c -msse2 -
mtune=i486 -o test.i
ignoring nonexistent directory "/usr/lib/gcc/i486-slackware-
linux/3.4.0/../../../../i486-slackware-linux/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/i486-slackware-linux/3.4.0/include
/usr/include
End of search list.
/usr/libexec/gcc/i486-slackware-linux/3.4.0/cc1 -fpreprocessed test.i -quiet -
dumpbase test.c -msse2 -mtune=i486 -auxbase test -version -o test.s
GNU C version 3.4.0 (i486-slackware-linux)
compiled by GNU C version 3.4.0.
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64518
/usr/lib/gcc/i486-slackware-linux/3.4.0/../../../../i486-slackware-
linux/bin/as -V -Qy -o test.o test.s
GNU assembler version 2.15.90.0.3 (i486-slackware-linux) using BFD version
2.15.90.0.3 20040415
/usr/libexec/gcc/i486-slackware-linux/3.4.0/collect2 --eh-frame-hdr -m
elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/gcc/i486-slackware-
linux/3.4.0/../../../crt1.o /usr/lib/gcc/i486-slackware-
linux/3.4.0/../../../crti.o /usr/lib/gcc/i486-slackware-linux/3.4.0/crtbegin.o -
L/usr/lib/gcc/i486-slackware-linux/3.4.0 -L/usr/lib/gcc/i486-slackware-
linux/3.4.0 -L/usr/lib/gcc/i486-slackware-linux/3.4.0/../../../../i486-
slackware-linux/lib -L/usr/lib/gcc/i486-slackware-linux/3.4.0/../../.. test.o -
lgcc -lgcc_eh -lc -lgcc -lgcc_eh /usr/lib/gcc/i486-slackware-
linux/3.4.0/crtend.o /usr/lib/gcc/i486-slackware-linux/3.4.0/../../../crtn.o
Also tested and found under gcc-3.3.4
--
Summary: -msse2 also enabling -mfpmath=sse option causing illegal
instruction errors
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: aron-gcc at sightspeed dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16584