Created attachment 617789 [details] A reduced test case for the problem. Description of problem: Using the glibc function for FMA (floating-point multiply and accumulate) the sign of the value returned by fma is incorrect. This only seems to happen when the product is -0 and the term to be added is -0. I think the result should be -0 but +0 is returned. I've used ddd to trace which exact instructions are used and it appears to be fmaf_sse2 and fma_sse2 which are respectively aliases for __fmaf and __fma. However copying these from the glibc source seems to give the right result suggesting the problem is somewhere in the 'glue' between the entrance to the dynamic library and the actual code that gets called or is a compilation issue with libc. Version-Release number of selected component (if applicable): $ uname -a Linux clpc20.cs.ox.ac.uk 2.6.38.6-27.fc15.x86_64 #1 SMP Sun May 15 17:23:28 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux $ ls -la /lib/libc* -rwxr-xr-x 1 root root 1858296 Feb 21 2012 /lib/libc-2.14.1.so <snip> lrwxrwxrwx 1 root root 14 Mar 15 2012 /lib/libc.so.6 -> libc-2.14.1.so ]$ rpm -qi glibc Name : glibc Version : 2.14.1 Release : 6 Architecture: x86_64 Install Date: Thu 15 Mar 2012 12:28:28 PM GMT Group : System Environment/Libraries Size : 13042256 License : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ Signature : RSA/SHA256, Tue 21 Feb 2012 06:10:35 PM GMT, Key ID b4ebf579069c8460 Source RPM : glibc-2.14.1-6.src.rpm Build Date : Tue 21 Feb 2012 04:53:38 AM GMT Build Host : x86-18.phx2.fedoraproject.org Relocations : (not relocatable) Packager : Fedora Project Vendor : Fedora Project URL : http://www.gnu.org/software/glibc/ Summary : The GNU libc libraries Description : The glibc package contains standard libraries which are used by multiple programs on the system. In order to save disk space and memory, as well as to make upgrading easier, common system code is kept in one place and shared between programs. This particular package contains the most important sets of shared libraries: the standard C library and the standard math library. Without these two libraries, a Linux system will not function. Name : glibc Version : 2.14.1 Release : 6 Architecture: i686 Install Date: Thu 15 Mar 2012 12:28:32 PM GMT Group : System Environment/Libraries Size : 13774016 License : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+ Signature : RSA/SHA256, Tue 21 Feb 2012 06:16:55 PM GMT, Key ID b4ebf579069c8460 Source RPM : glibc-2.14.1-6.src.rpm Build Date : Tue 21 Feb 2012 05:18:17 AM GMT Build Host : x86-06.phx2.fedoraproject.org Relocations : (not relocatable) Packager : Fedora Project Vendor : Fedora Project URL : http://www.gnu.org/software/glibc/ Summary : The GNU libc libraries Description : The glibc package contains standard libraries which are used by multiple programs on the system. In order to save disk space and memory, as well as to make upgrading easier, common system code is kept in one place and shared between programs. This particular package contains the most important sets of shared libraries: the standard C library and the standard math library. Without these two libraries, a Linux system will not function. $ cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 23 model name : Intel(R) Core(TM)2 Quad CPU Q9550 @ 2.83GHz stepping : 10 cpu MHz : 2000.000 cache size : 6144 KB physical id : 0 siblings : 4 core id : 0 cpu cores : 4 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dts tpr_shadow vnmi flexpriority bogomips : 5651.90 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management: <snip> $ g++ --version g++ (GCC) 4.6.3 20120306 (Red Hat 4.6.3-2) Copyright (C) 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. How reproducible: Works reliably on this machine. An x86 Debian box I tried this on gives the correct results. Steps to Reproduce: 1. g++ -frounding-math -fsignaling-nans -mfpmath=sse glibc-sign-issue.c -o glibc-sign-issue 2. ./glibc-sign-issue Actual results: $ ./glibc-sign-issue -0==0 don't match -0==-0 match Expected results: $ ./glibc-sign-issue -0==-0 match -0==-0 match Additional info:
I've further reduced the test and attached it to upstream bug #13304 which is tracking a variety of fma problems within glibc. If/when upstream fixes this problem we'll pick it up for Fedora via our usual resyncing processes.
FYI, there's a build in rawhide spinning with a fix for this problem.