From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9561 invoked by alias); 16 Jul 2004 02:47:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 9550 invoked by uid 48); 16 Jul 2004 02:46:59 -0000 Date: Fri, 16 Jul 2004 02:47:00 -0000 From: "aron-gcc at sightspeed dot com" To: gcc-bugs@gcc.gnu.org Message-ID: <20040716024656.16584.aron-gcc@sightspeed.com> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c/16584] New: -msse2 also enabling -mfpmath=sse option causing illegal instruction errors X-Bugzilla-Reason: CC X-SW-Source: 2004-07/txt/msg01970.txt.bz2 List-Id: 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 int main(void) { int i = 1; float temp2 = 1.0 * (i*i); // Allow for an optimal sse2 int to float conversion return 0; } 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" 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. # 1 "test.c" # 1 "" # 1 "" # 1 "test.c" int main(void) { int i = 1; float temp2 = 1.0 * (i*i); return 0; } 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