--------------------------------- cat >bug.c<<EOF #include <stdlib.h> typedef int di __attribute__ ((mode(DI))); double x; di mm; double f () { return 1.0; } void f2 () { x = f (); mm = __builtin_ia32_pxor (mm, mm); /* clear MMX state after using MMX unit */ __builtin_ia32_emms (); } int main () { f2 (); if (x != 1.0) abort (); return 0; } EOF gcc -O2 -mmmx bug.c -o bug ./bug --------------------------------- I get 'Aborted' with 3.3.4, 3.4.0, 3.5.0, and do not get it if I compile this with -O1. Below is an assembly code for f2 (), compiled with today's 3.4.0: f2: pushl %ebp # movl %esp, %ebp #, call f # movq mm, %mm0 # mm, mm fstpl x # x pxor %mm0, %mm0 #, mm movq %mm0, mm # mm, mm emms leave ret FPU insns should not be mixed with MMX ones, or they will fail.
Confirmed, the problem is with the schedular, using -fno-schedule-insns2 "fixes" the problem.
This is better bug still a problem, right? pushl %ebp movl %esp, %ebp call f pxor %mm0, %mm0 movq %mm0, mm fstpl x emms popl %ebp ret
*** Bug 16872 has been marked as a duplicate of this bug. ***
*** This bug has been marked as a duplicate of 19161 ***