Bug#560812: gcc-4.4: Incorrect 3DNow! code generated
Package: gcc-4.4
Version: 4.4.2-4
Severity: important
*** Please type your report below this line ***
With the following simple test file, the 3DNow! generated code is
incorrect, with final _m_pfsub generated as pfsubr %mm0,%mm0, thus
producing completely incorrect result.
*** main.c
#include <mm3dnow.h>
void Butterfly_3(__m64 *D,__m64 SC,unsigned int IStep,unsigned int Off)
{ __m64 T,T1,T2;
T=_m_pfmul(D[Off+1],SC);
T1=D[Off+0];D[Off+0]=_m_pfadd(T1,T);D[Off+1]=_m_pfsub(T1,T);
}
***
The command line is:
gcc -march=athlon -S -O3 main.c
The generated code is:
*** main.s
.file "main.c"
.text
.p2align 4,,15
.globl Butterfly_3
.type Butterfly_3, @function
Butterfly_3:
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %edx
movl 16(%ebp), %ecx
leal 8(%edx,%ecx,8), %eax
leal (%edx,%ecx,8), %edx
pfmul (%eax), %mm0
movq (%edx), %mm1
movq %mm1, %mm2
pfadd %mm0, %mm2
pfsubr %mm0, %mm0
movq %mm2, (%edx)
movq %mm0, (%eax)
leave
ret
.size Butterfly_3, .-Butterfly_3
.ident "GCC: (Debian 4.4.2-4) 4.4.2"
.section .note.GNU-stack,"",@progbits
***
The problem exists in all current Debian releases (stable, testing,
unstable).
Without optimizations the problem is still there, but it's a lot more
difficult to follow.
This is the simplest test code that I could extract. The basic principle
is used in a large
cross-platform library and all GCC variants for x86 that I have used
(Debian, Cygwin, MinGW, TDM)
generate essentially the same code.
-- System Information:
Debian Release: squeeze/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.31-1-686 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages gcc-4.4 depends on:
ii binutils 2.20-4 The GNU assembler, linker
and bina
ii cpp-4.4 4.4.2-4 The GNU C preprocessor
ii gcc-4.4-base 4.4.2-4 The GNU Compiler Collection
(base
ii libc6 2.10.2-2 GNU C Library: Shared libraries
ii libgcc1 1:4.4.2-4 GCC support library
ii libgomp1 4.4.2-4 GCC OpenMP (GOMP) support
library
Versions of packages gcc-4.4 recommends:
ii libc6-dev 2.10.2-2 GNU C Library: Development
Librari
Versions of packages gcc-4.4 suggests:
pn gcc-4.4-doc <none> (no description available)
pn gcc-4.4-locales <none> (no description available)
pn gcc-4.4-multilib <none> (no description available)
pn libcloog-ppl0 <none> (no description available)
pn libgcc1-dbg <none> (no description available)
pn libgomp1-dbg <none> (no description available)
pn libmudflap0-4.4-dev <none> (no description available)
pn libmudflap0-dbg <none> (no description available)
pn libppl-c2 <none> (no description available)
pn libppl7 <none> (no description available)
-- no debconf information
Reply to: