This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug optimization/14801] New: wrong-code, gcc -O2 mixed FPU and MMX instructions


---------------------------------
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.

-- 
           Summary: wrong-code, gcc -O2 mixed FPU and MMX instructions
           Product: gcc
           Version: 3.3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: 1319 at bot dot ru
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14801


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]