|
|
147e83 |
commit 38f3458175ecf7c3588bd5b6e465f4d9205fbe1c
|
|
|
147e83 |
Author: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
|
|
|
147e83 |
Date: Wed Jan 8 05:10:41 2014 -0600
|
|
|
147e83 |
|
|
|
147e83 |
PowerPC: remove wrong truncl implementation for PowerPC64
|
|
|
147e83 |
|
|
|
147e83 |
The truncl assembly implementation (sysdeps/powerpc/powerpc64/fpu/s_truncl.S)
|
|
|
147e83 |
returns wrong results for some inputs where first double is a exact integer
|
|
|
147e83 |
and the precision is determined by second long double.
|
|
|
147e83 |
|
|
|
147e83 |
Checking on implementation comments and history, I am very confident the
|
|
|
147e83 |
assembly implementation was based on a version before commit
|
|
|
147e83 |
5c68d401698a58cf7da150d9cce769fa6679ba5f that fixes BZ#2423 (Errors in
|
|
|
147e83 |
long double (ldbl-128ibm) rounding functions in glibc-2.4).
|
|
|
147e83 |
|
|
|
147e83 |
By just removing the implementation and make the build select
|
|
|
147e83 |
sysdeps/ieee754/ldbl-128ibm/s_truncl.c instead it fixes tgammal
|
|
|
147e83 |
issues regarding wrong result sign.
|
|
|
147e83 |
|
|
|
147e83 |
Index: b/sysdeps/ieee754/ldbl-128ibm/s_truncl.c
|
|
|
147e83 |
===================================================================
|
|
|
147e83 |
--- a/sysdeps/ieee754/ldbl-128ibm/s_truncl.c
|
|
|
147e83 |
+++ b/sysdeps/ieee754/ldbl-128ibm/s_truncl.c
|
|
|
147e83 |
@@ -17,9 +17,6 @@
|
|
|
147e83 |
License along with the GNU C Library; if not, see
|
|
|
147e83 |
<http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
|
|
|
147e83 |
-/* This has been coded in assembler because GCC makes such a mess of it
|
|
|
147e83 |
- when it's coded in C. */
|
|
|
147e83 |
-
|
|
|
147e83 |
#include <math.h>
|
|
|
147e83 |
#include <math_ldbl_opt.h>
|
|
|
147e83 |
#include <float.h>
|
|
|
147e83 |
Index: b/sysdeps/powerpc/powerpc64/fpu/s_truncl.S
|
|
|
147e83 |
===================================================================
|
|
|
147e83 |
--- a/sysdeps/powerpc/powerpc64/fpu/s_truncl.S
|
|
|
147e83 |
+++ /dev/null
|
|
|
147e83 |
@@ -1,120 +0,0 @@
|
|
|
147e83 |
-/* long double trunc function.
|
|
|
147e83 |
- IBM extended format long double version.
|
|
|
147e83 |
- Copyright (C) 2004, 2006 Free Software Foundation, Inc.
|
|
|
147e83 |
- This file is part of the GNU C Library.
|
|
|
147e83 |
-
|
|
|
147e83 |
- The GNU C Library is free software; you can redistribute it and/or
|
|
|
147e83 |
- modify it under the terms of the GNU Lesser General Public
|
|
|
147e83 |
- License as published by the Free Software Foundation; either
|
|
|
147e83 |
- version 2.1 of the License, or (at your option) any later version.
|
|
|
147e83 |
-
|
|
|
147e83 |
- The GNU C Library is distributed in the hope that it will be useful,
|
|
|
147e83 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
147e83 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
147e83 |
- Lesser General Public License for more details.
|
|
|
147e83 |
-
|
|
|
147e83 |
- You should have received a copy of the GNU Lesser General Public
|
|
|
147e83 |
- License along with the GNU C Library; if not, see
|
|
|
147e83 |
- <http://www.gnu.org/licenses/>. */
|
|
|
147e83 |
-
|
|
|
147e83 |
-#include <sysdep.h>
|
|
|
147e83 |
-#include <math_ldbl_opt.h>
|
|
|
147e83 |
-
|
|
|
147e83 |
- .section ".toc","aw"
|
|
|
147e83 |
-.LC0: /* 2**52 */
|
|
|
147e83 |
- .tc FD_43300000_0[TC],0x4330000000000000
|
|
|
147e83 |
-.LC1: /* 0.5 */
|
|
|
147e83 |
- .tc FD_3fe00000_0[TC],0x3fe0000000000000
|
|
|
147e83 |
- .section ".text"
|
|
|
147e83 |
-
|
|
|
147e83 |
-/* long double [fp1,fp2] truncl (long double x [fp1,fp2]) */
|
|
|
147e83 |
-
|
|
|
147e83 |
-ENTRY (__truncl)
|
|
|
147e83 |
- mffs fp11 /* Save current FPU rounding mode. */
|
|
|
147e83 |
- lfd fp13,.LC0@toc(2)
|
|
|
147e83 |
- fabs fp0,fp1
|
|
|
147e83 |
- fabs fp9,fp2
|
|
|
147e83 |
- fsub fp12,fp13,fp13 /* generate 0.0 */
|
|
|
147e83 |
- fcmpu cr7,fp0,fp13 /* if (fabs(x) > TWO52) */
|
|
|
147e83 |
- fcmpu cr6,fp1,fp12 /* if (x > 0.0) */
|
|
|
147e83 |
- bnl- cr7,.L2
|
|
|
147e83 |
- mtfsfi 7,1 /* Set rounding mode toward 0. */
|
|
|
147e83 |
- ble- cr6,.L1
|
|
|
147e83 |
- fneg fp2,fp12
|
|
|
147e83 |
- fadd fp1,fp1,fp13 /* x+= TWO52; */
|
|
|
147e83 |
- fsub fp1,fp1,fp13 /* x-= TWO52; */
|
|
|
147e83 |
- fabs fp1,fp1 /* if (x == 0.0) x = 0.0; */
|
|
|
147e83 |
-.L0:
|
|
|
147e83 |
- mtfsf 0x01,fp11 /* restore previous rounding mode. */
|
|
|
147e83 |
- blr
|
|
|
147e83 |
-.L1:
|
|
|
147e83 |
- fneg fp2,fp12
|
|
|
147e83 |
- bge- cr6,.L0 /* if (x < 0.0) */
|
|
|
147e83 |
- fsub fp1,fp1,fp13 /* x-= TWO52; */
|
|
|
147e83 |
- fadd fp1,fp1,fp13 /* x+= TWO52; */
|
|
|
147e83 |
- fnabs fp1,fp1 /* if (x == 0.0) x = -0.0; */
|
|
|
147e83 |
- mtfsf 0x01,fp11 /* restore previous rounding mode. */
|
|
|
147e83 |
- blr
|
|
|
147e83 |
-
|
|
|
147e83 |
-/* The high double is > TWO52 so we need to round the low double and
|
|
|
147e83 |
- perhaps the high double. In this case we have to round the low
|
|
|
147e83 |
- double and handle any adjustment to the high double that may be
|
|
|
147e83 |
- caused by rounding (up). This is complicated by the fact that the
|
|
|
147e83 |
- high double may already be rounded and the low double may have the
|
|
|
147e83 |
- opposite sign to compensate.This gets a bit tricky so we use the
|
|
|
147e83 |
- following algorithm:
|
|
|
147e83 |
-
|
|
|
147e83 |
- tau = floor(x_high/TWO52);
|
|
|
147e83 |
- x0 = x_high - tau;
|
|
|
147e83 |
- x1 = x_low + tau;
|
|
|
147e83 |
- r1 = rint(x1);
|
|
|
147e83 |
- y_high = x0 + r1;
|
|
|
147e83 |
- y_low = x0 - y_high + r1;
|
|
|
147e83 |
- return y; */
|
|
|
147e83 |
-.L2:
|
|
|
147e83 |
- fcmpu cr7,fp9,fp13 /* if (|x_low| > TWO52) */
|
|
|
147e83 |
- fcmpu cr0,fp9,fp12 /* || (|x_low| == 0.0) */
|
|
|
147e83 |
- fcmpu cr5,fp2,fp12 /* if (x_low > 0.0) */
|
|
|
147e83 |
- bgelr- cr7 /* return x; */
|
|
|
147e83 |
- beqlr- cr0
|
|
|
147e83 |
- mtfsfi 7,1 /* Set rounding mode toward 0. */
|
|
|
147e83 |
- fdiv fp8,fp1,fp13 /* x_high/TWO52 */
|
|
|
147e83 |
-
|
|
|
147e83 |
- bng- cr6,.L6 /* if (x > 0.0) */
|
|
|
147e83 |
- fctidz fp0,fp8
|
|
|
147e83 |
- fcfid fp8,fp0 /* tau = floor(x_high/TWO52); */
|
|
|
147e83 |
- fadd fp8,fp8,fp8 /* tau++; Make tau even */
|
|
|
147e83 |
- bng cr5,.L4 /* if (x_low > 0.0) */
|
|
|
147e83 |
- fmr fp3,fp1
|
|
|
147e83 |
- fmr fp4,fp2
|
|
|
147e83 |
- b .L5
|
|
|
147e83 |
-.L4: /* if (x_low < 0.0) */
|
|
|
147e83 |
- fsub fp3,fp1,fp8 /* x0 = x_high - tau; */
|
|
|
147e83 |
- fadd fp4,fp2,fp8 /* x1 = x_low + tau; */
|
|
|
147e83 |
-.L5:
|
|
|
147e83 |
- fadd fp5,fp4,fp13 /* r1 = r1 + TWO52; */
|
|
|
147e83 |
- fsub fp5,fp5,fp13 /* r1 = r1 - TWO52; */
|
|
|
147e83 |
- b .L9
|
|
|
147e83 |
-.L6: /* if (x < 0.0) */
|
|
|
147e83 |
- fctidz fp0,fp8
|
|
|
147e83 |
- fcfid fp8,fp0 /* tau = floor(x_high/TWO52); */
|
|
|
147e83 |
- fadd fp8,fp8,fp8 /* tau++; Make tau even */
|
|
|
147e83 |
- bnl cr5,.L7 /* if (x_low < 0.0) */
|
|
|
147e83 |
- fmr fp3,fp1
|
|
|
147e83 |
- fmr fp4,fp2
|
|
|
147e83 |
- b .L8
|
|
|
147e83 |
-.L7: /* if (x_low > 0.0) */
|
|
|
147e83 |
- fsub fp3,fp1,fp8 /* x0 = x_high - tau; */
|
|
|
147e83 |
- fadd fp4,fp2,fp8 /* x1 = x_low + tau; */
|
|
|
147e83 |
-.L8:
|
|
|
147e83 |
- fsub fp5,fp4,fp13 /* r1-= TWO52; */
|
|
|
147e83 |
- fadd fp5,fp5,fp13 /* r1+= TWO52; */
|
|
|
147e83 |
-.L9:
|
|
|
147e83 |
- mtfsf 0x01,fp11 /* restore previous rounding mode. */
|
|
|
147e83 |
- fadd fp1,fp3,fp5 /* y_high = x0 + r1; */
|
|
|
147e83 |
- fsub fp2,fp3,fp1 /* y_low = x0 - y_high + r1; */
|
|
|
147e83 |
- fadd fp2,fp2,fp5
|
|
|
147e83 |
- blr
|
|
|
147e83 |
-END (__truncl)
|
|
|
147e83 |
-
|
|
|
147e83 |
-long_double_symbol (libm, __truncl, truncl)
|