http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53485
Bug #: 53485 Summary: gcc -O -mavx generates illegal instruction on win64 Classification: Unclassified Product: gcc Version: 4.6.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: i...@nasoftware.co.uk Created attachment 27495 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27495 preprocessed source Compiling the attached program with optimization and AVX for Win64 generates an illegal instruction. The same code runs correctly on Win32 and on Linux64. $ x86_64-w64-mingw32-gcc -m64 -mavx bug.c -O -g -o bug.exe -Wall -Wextra -save-temps $ ./bug.exe BUG PROGRAM START: We should get this message once. DEBUG fun1 start... Illegal instruction $ gdb bug.exe (gdb) r Starting program: C:\cygwin\home\nas/bug.exe [New Thread 2436.0x38c] BUG PROGRAM START: We should get this message once. DEBUG fun1 start... Program received signal SIGILL, Illegal instruction. fun1 () at bug.c:95 95 v1 = vfone; (gdb) x/i $pc => 0x4015e7 <fun1+54>: vmovaps 0x7b11(%rip),%ymm0 # 0x409100 (gdb) p $rip $1 = (void (*)()) 0x4015e7 <fun1+54> (gdb) info frame Stack level 0, frame at 0x22fe40: rip = 0x4015e7 in fun1 (bug.c:95); saved rip 0x40171b called by frame at 0x22fe70 source language c. Arglist at 0x22fe30, args: Locals at 0x22fe30, Previous frame's sp is 0x22fe40 Saved registers: rbx at 0x22fe20, rsi at 0x22fe28, rbp at 0x22fe30, rip at 0x22fe38, xmm15 at 0x22fe38 $ x86_64-w64-mingw32-gcc -v Using built-in specs. COLLECT_GCC=C:\cygwin\home\nas\mingw64\bin\x86_64-w64-mingw32-gcc.exe COLLECT_LTO_WRAPPER=c:/cygwin/home/nas/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/4.6.3/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: /home/drangon/work/mingw-w64-dgn/source/gcc/configure --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --disable-nls --enable-languages=c,c++,objc,obj-c++ --with-gmp=/home/drangon/work/mingw-w64-dgn/build/for_target --enable-twoprocess --disable-libstdcxx-pch --disable-win32-registry --prefix=/home/drangon/work/mingw-w64-dgn/target --with-sysroot=/home/drangon/work/mingw-w64-dgn/target Thread model: win32 gcc version 4.6.3 20120225 (prerelease) (GCC) I have also tried the mingw64 cross compiler from http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Automated%20Builds/ gcc version 4.8.0 20120509 (experimental) (GCC) and I get the same error (though I need to use -O3) If I download an older version, gcc version 4.5.4 20111030 (prerelease) [svn/rev.180676 - mingw-w64/oz] (GCC) then I don't get the illegal instruction.