Bug#860823: gcc-6: sqrt x64 intrinsic broken with -O3 and -ffast-math
Package: gcc-6 Version: 6.3.0-12 Severity: normal After being "hit" by unexplained division by 0 related crashes of an application, the following simple test code shows the issue: #include #include void TestSqrt(const float *Src,float *Dest,size_t Size,float &Gain) { while (Size--) { float G,X; G=sqrt(X=*Src++); if (G) { Gain=Gain*0.9f+1/G*0.1f; X*=Gain; } *Dest++=X; } } The compile and listing generating where done using: gcc -O3 -m64 -ffast-math -c -o sqrt.o sqrt.cpp objdump -M intel -S -r -C sqrt.o > sqrt.lst The "sqrt" coresponding piece of code looks like: 30: f3 0f 10 0c 87 movss xmm1,DWORD PTR [rdi+rax*4] 35: f3 0f 52 d1 rsqrtss xmm2,xmm1 39: 0f 28 c2movaps xmm0,xmm2 3c: 0f 2f cbcomiss xmm1,xmm3 3f: f3 0f 59 c1 mulss xmm0,xmm1 43: f3 0f 59 c2 mulss xmm0,xmm2 47: f3 0f 59 d4 mulss xmm2,xmm4 4b: f3 0f 58 c5 addss xmm0,xmm5 4f: f3 0f 59 c2 mulss xmm0,xmm2 53: 74 18 je 6d 55: f3 0f 10 11 movss xmm2,DWORD PTR [rcx] 59: f3 0f 59 c6 mulss xmm0,xmm6 5d: f3 0f 59 d7 mulss xmm2,xmm7 61: f3 0f 58 c2 addss xmm0,xmm2 65: f3 0f 59 c8 mulss xmm1,xmm0 69: f3 0f 11 01 movss DWORD PTR [rcx],xmm0 6d: f3 0f 11 0c 86 movss DWORD PTR [rsi+rax*4],xmm1 72: 48 83 c0 01 addrax,0x1 76: 48 39 c2cmprdx,rax 79: 75 b5 jne30 The generated code is not handling in any way the case of 0 as input value. As per Intel spec, rsqrtss has an +/-INF result when the input is 0 and the final results of the test code is unpredictable, while 0 is a perfect valid input value for sqrt. Regards, Catalin -- System Information: Debian Release: 9.0 APT prefers testing APT policy: (500, 'testing') Architecture: amd64 (x86_64) Kernel: Linux 4.9.0-2-amd64 (SMP w/2 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages gcc-6 depends on: ii binutils 2.28-3 ii cpp-6 6.3.0-12 ii gcc-6-base6.3.0-12 ii libc6 2.24-9 ii libcc1-0 6.3.0-12 ii libgcc-6-dev 6.3.0-12 ii libgcc1 1:6.3.0-12 ii libgmp10 2:6.1.2+dfsg-1 ii libisl15 0.18-1 ii libmpc3 1.0.3-1+b2 ii libmpfr4 3.1.5-1 ii libstdc++66.3.0-12 ii zlib1g1:1.2.8.dfsg-5 Versions of packages gcc-6 recommends: ii libc6-dev 2.24-9 Versions of packages gcc-6 suggests: pn gcc-6-doc pn gcc-6-locales pn gcc-6-multilib pn libasan3-dbg pn libatomic1-dbg pn libcilkrts5-dbg pn libgcc1-dbg pn libgomp1-dbg pn libitm1-dbg pn liblsan0-dbg pn libmpx2-dbg pn libquadmath0-dbg pn libtsan0-dbg pn libubsan0-dbg -- no debconf information
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 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 .typeButterfly_3, @function Butterfly_3: pushl%ebp movl%esp, %ebp movl8(%ebp), %edx movl16(%ebp), %ecx leal8(%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 .sizeButterfly_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-4The GNU C preprocessor ii gcc-4.4-base 4.4.2-4The 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-4GCC 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(no description available) pn gcc-4.4-locales(no description available) pn gcc-4.4-multilib (no description available) pn libcloog-ppl0 (no description available) pn libgcc1-dbg(no description available) pn libgomp1-dbg (no description available) pn libmudflap0-4.4-dev(no description available) pn libmudflap0-dbg(no description available) pn libppl-c2 (no description available) pn libppl7(no description available) -- no debconf information -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Bug#560282: gcc-4.4: cc1 crashes with simple test file
Please consider this one closed! In the end it proved to be a CIFS related problem. By copying the test file on a local file system everything works as far as this bug is concerned. Even GCC 4.3.4 that previously worked is now failing with the same rather strange error. Matthias Klose wrote: > severity 560282 normal > thanks > > builds without errors. closing. please reopen if you can reproduce > this on another machine, and provide maybe a complete example which > shows the error. > > On 10.12.2009 09:47, Catalin Ionescu wrote: >> Package: gcc-4.4 >> Version: 4.4.2-3 >> Severity: critical >> >> >> When trying to compile the following very simple test file: >> >> *** main.c >> #include >> >> 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 following error appears: >> >> cc1: error: main.c: Value too large for defined data type >> >> The command line is: >> >> gcc -march=athlon -fverbose-asm -S -O3 main.c >> >> The same source file compiles with GCC 4.3.2 and GCC 4.3.4 as they >> are in fully >> updated Debian stable and testing releases. -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Bug#560282: gcc-4.4: cc1 crashes with simple test file
With fresh install of Debian Unstable the error is still present. By using: gcc -march=athlon -fverbose-asm -S -O3 -save-temps main.c all I see is an empty (0 bytes) main.i file and compile process still ends with "cc1: error: main.c: Value too large for defined data type" -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Bug#560282: gcc-4.4: cc1 crashes with simple test file
Right now I see gcc 4.4.2-4 available for Debian unstable. I have upgraded the compilers but I still get: "cc1: error: main.c: Value too large for defined data type" This is a Virtual Box installed Debian unstable. With older GCC versions, 4.3.2 (Debian stable) and 4.3.4 (Debian testing) the same code produced incorrect output, still on Virtual Box machines. I will try a new, clean install of Debian unstable and see if I can still reproduce this bug. -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Bug#560282: gcc-4.4: cc1 crashes with simple test file
Package: gcc-4.4 Version: 4.4.2-3 Severity: critical When trying to compile the following very simple test file: *** main.c #include 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 following error appears: cc1: error: main.c: Value too large for defined data type The command line is: gcc -march=athlon -fverbose-asm -S -O3 main.c The same source file compiles with GCC 4.3.2 and GCC 4.3.4 as they are in fully updated Debian stable and testing releases. -- 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-3The GNU C preprocessor ii gcc-4.4-base 4.4.2-3The GNU Compiler Collection (base ii libc6 2.10.2-2 GNU C Library: Shared libraries ii libgcc1 1:4.4.2-3 GCC support library ii libgomp1 4.4.2-3GCC 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(no description available) pn gcc-4.4-locales(no description available) pn gcc-4.4-multilib (no description available) pn libcloog-ppl0 (no description available) pn libgcc1-dbg(no description available) pn libgomp1-dbg (no description available) pn libmudflap0-4.4-dev(no description available) pn libmudflap0-dbg(no description available) pn libppl-c2 (no description available) pn libppl7(no description available) -- no debconf information -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Bug#558245: gcc-4.3: Broken 3DNow! built-ins with optimization turned on
Package: gcc-4.3 Version: 4.3.2-1.1 Severity: important With the attached source file, the code generated is incorrect for the final _m_pfsub. The compiler generates things like PFSUBR %MM0,%MM0. The command line showing the problem is: gcc -march=athlon -fverbose-asm -S -O3 main.c Removing '-O3' from the command line generates correct, but not optimized, code. The problem is visible in both GCC 4.3.2 (Debian Lenny) and GCC 4.3.4-6 (Debian Squeeze). *** main.c #include 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); } -- System Information: Debian Release: 5.0.3 APT prefers stable APT policy: (500, 'stable') Architecture: i386 (i686) Kernel: Linux 2.6.26-2-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/bash Versions of packages gcc-4.3 depends on: ii binutils2.18.1~cvs20080103-7 The GNU assembler, linker and bina ii cpp-4.3 4.3.2-1.1The GNU C preprocessor ii gcc-4.3-base4.3.2-1.1The GNU Compiler Collection (base ii libc6 2.7-18 GNU C Library: Shared libraries ii libgcc1 1:4.3.2-1.1 GCC support library ii libgomp14.3.2-1.1GCC OpenMP (GOMP) support library Versions of packages gcc-4.3 recommends: ii libc6-dev 2.7-18 GNU C Library: Development Librari Versions of packages gcc-4.3 suggests: pn gcc-4.3-doc(no description available) pn gcc-4.3-locales(no description available) pn gcc-4.3-multilib (no description available) pn libgcc1-dbg(no description available) pn libgomp1-dbg (no description available) pn libmudflap0-4.3-dev(no description available) pn libmudflap0-dbg(no description available) -- no debconf information -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org