This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug math/16600] New: Glibc floating-point tests fail on VFPv4 platforms
- From: "y.gribov at samsung dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Tue, 18 Feb 2014 07:16:15 +0000
- Subject: [Bug math/16600] New: Glibc floating-point tests fail on VFPv4 platforms
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=16600
Bug ID: 16600
Summary: Glibc floating-point tests fail on VFPv4 platforms
Product: glibc
Version: 2.21
Status: NEW
Severity: normal
Priority: P2
Component: math
Assignee: unassigned at sourceware dot org
Reporter: y.gribov at samsung dot com
CC: jsm28 at gcc dot gnu.org, v.garbuzov at samsung dot com
Target: arm*-*-*
Created attachment 7424
--> https://sourceware.org/bugzilla/attachment.cgi?id=7424&action=edit
Testcase for powf failure
I've recently tried rebuilding glibc trunk for Cortex-A15 with -mfpu=vfpv4
compiler flags
and ran into some issues with glibc regression tests. Attached testcase
illustrates the issue:
Glibc built for VFPv3 yields 0x1.477db2p+2:
$ arm-v7a15-linux-gnueabi-gcc -O0 -fno-builtin powf_test.c -lm
$ LD_LIBRARY_PATH=/vfpv3-master ./a.out
powf(1.1875f, 9.5f) == 5.11705 0x1.477db2p+2
pow(1.1875, 9.5) == 5.11705 0x1.477db2p+2
but Glibc built for VFPv4 yields different result, 0x1.477dbp+2:
$ LD_LIBRARY_PATH=/vfpv4-master ./a.out
powf(1.1875f, 9.5f) == 5.11705 0x1.477dbp+2
pow(1.1875, 9.5) == 5.11705 0x1.477db2p+2
Note that for both versions double-precision result is 0x1.477db2p+2
(i.e. matching single-precision VFPv3).
After some investigation I discovered that differences are caused
by fused-multiply-add instructions (vfma and friends) in VFPv4.
Their results may be different from VFPv3's fmac family
(because of extra precision bits in fused instructions).
I have attached a trivial testcase which shows how x + y*z
gives different results on VFPv3 and VFPv4:
VFPv4 (vfma and unfused operations yield different results):
$ arm-v7a15-linux-gnueabi-gcc -O2 -mfpu=vfpv4 mad.c
$ ./a.out
Multiply and add : -0.118126 -0x1.e3d8p-4 3186748416
Multiply and add (fused): -0.118126 -0x1.e3d80cp-4 3186748422
Multiply and add (exact): -0.118126 -0x1.e3d80cp-4 3186748422
So in summary, trunk glibc built with -mfpu=vfpv4
returns unexpected results from standard math functions like powf.
Platform info:
1) I'm using trunk glibc (Feb 17 2014) and GCC (r207777).
2) Cross GCC VFPv3 was configured with
$HOME/gcc/gcc-master/configure --build=x86_64-pc-linux-gnu
--host=x86_64-pc-linux-gnu --target=arm-v7a15-linux-gnueabi
--prefix=/home/ygribov/install/gcc-master-arm-full-vfpv3
--with-sysroot=/home/ygribov/install/gcc-master-arm-full-vfpv3/arm-v7a15-linux-gnueabi/sys-root/
--disable-libmudflap --disable-libssp --disable-nls --disable-libstdcxx-pch
--with-interwork --with-mode=arm --with-fpu=vfpv3 --with-cpu=cortex-a15
--with-tune=cortex-a15 --with-float=softfp --enable-libgomp
--enable-poison-system-directories --enable-long-long --enable-threads
--enable-languages=c,c++ --enable-shared --with-gnu-as --with-gnu-ld
--with-build-time-tools=/home/ygribov/install/gcc-master-arm-full-vfpv3
3) Cross GCC VFPv4 is same but --with-fpu=vfpv4.
4) Glibc VFPv3 was configured with
$ PATH=~/install/gcc-master-arm-full-vfpv3/bin:$PATH
~/src/glibc-master/configure --prefix=/usr
--with-headers=/home/ygribov/install/gcc-master-arm-full-vfpv4/arm-v7a15-linux-gnueabi/sys-root/./usr/include
--build=x86_64-pc-linux-gnu --host=arm-v7a15-linux-gnueabi --disable-profile
--without-gd --without-cvs --enable-kernel= --disable-multi-arch
5) Glibc VFPv4 is same but with VFPv4 cross-compiler.
--
You are receiving this mail because:
You are on the CC list for the bug.