]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
PowerPC: remove wrong truncl implementation for PowerPC64
authorAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Thu, 23 Jan 2014 17:06:58 +0000 (11:06 -0600)
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Thu, 23 Jan 2014 17:06:58 +0000 (11:06 -0600)
The truncl assembly implementation (sysdeps/powerpc/powerpc64/fpu/s_truncl.S)
returns wrong results for some inputs where first double is a exact integer
and the precision is determined by second long double.

Checking on implementation comments and history, I am very confident the
assembly implementation was based on a version before commit
5c68d401698a58cf7da150d9cce769fa6679ba5f that fixes BZ#2423 (Errors in
long double (ldbl-128ibm) rounding functions in glibc-2.4).

By just removing the implementation and make the build select
sysdeps/ieee754/ldbl-128ibm/s_truncl.c instead it fixes tgammal
issues regarding wrong result sign.

ChangeLog
NEWS
sysdeps/ieee754/ldbl-128ibm/s_truncl.c
sysdeps/powerpc/powerpc64/fpu/s_truncl.S [deleted file]

index d8393677a54055b48441e2cb8a5952ee27c42e60..47607ed5dcc680c17ec0bd4ea879c7213b0bcc89 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2014-01-23  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
+
+       [BZ #16414]
+       * sysdeps/powerpc/powerpc64/fpu/s_truncl.S: Remove wrong
+       implementation.
+       * sysdeps/ieee754/ldbl-128ibm/s_truncl.c: Remove bogus comment.
+
 2014-01-23  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
 
        [BZ #14143]
diff --git a/NEWS b/NEWS
index 28b77555b28c7ba7d828bae56407994971fe3496..4190e85d7c645bf5f5b095f79cc78299b332d04d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,7 +10,8 @@ Version 2.18.1
 * The following bugs are resolved with this release:
 
   14143, 14155, 14547, 14699, 15532, 15427, 15522, 15680, 15723, 15734,
-  15735, 15797, 15892, 15895, 15909, 15917, 15996, 16072, 16150, 16430.
+  15735, 15797, 15892, 15895, 15909, 15917, 15996, 16072, 16150, 16414,
+  16430.
 
 * Support for powerpc64le has been added.
 
index 2765b63132116e0d93080a40caf983d4df81fac1..02bfc492f7ddc1b08a85fe4843266b9f1b7de304 100644 (file)
@@ -17,9 +17,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-/* This has been coded in assembler because GCC makes such a mess of it
-   when it's coded in C.  */
-
 #include <math.h>
 #include <math_ldbl_opt.h>
 #include <float.h>
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_truncl.S b/sysdeps/powerpc/powerpc64/fpu/s_truncl.S
deleted file mode 100644 (file)
index 06fd7db..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/* long double trunc function.
-   IBM extended format long double version.
-   Copyright (C) 2004-2013 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <math_ldbl_opt.h>
-
-       .section        ".toc","aw"
-.LC0:  /* 2**52 */
-       .tc FD_43300000_0[TC],0x4330000000000000
-.LC1:  /* 0.5 */
-       .tc FD_3fe00000_0[TC],0x3fe0000000000000
-       .section        ".text"
-
-/* long double [fp1,fp2] truncl (long double x [fp1,fp2])  */
-
-ENTRY (__truncl)
-       mffs    fp11            /* Save current FPU rounding mode.  */
-       lfd     fp13,.LC0@toc(2)
-       fabs    fp0,fp1
-       fabs    fp9,fp2
-       fsub    fp12,fp13,fp13  /* generate 0.0  */
-       fcmpu   cr7,fp0,fp13    /* if (fabs(x) > TWO52)  */
-       fcmpu   cr6,fp1,fp12    /* if (x > 0.0)  */
-       bnl-    cr7,.L2
-       mtfsfi  7,1             /* Set rounding mode toward 0.  */
-       ble-    cr6,.L1
-       fneg    fp2,fp12
-       fadd    fp1,fp1,fp13    /* x+= TWO52;  */
-       fsub    fp1,fp1,fp13    /* x-= TWO52;  */
-       fabs    fp1,fp1         /* if (x == 0.0) x = 0.0;  */
-.L0:
-       mtfsf   0x01,fp11       /* restore previous rounding mode.  */
-       blr
-.L1:
-       fneg    fp2,fp12
-       bge-    cr6,.L0         /* if (x < 0.0)  */
-       fsub    fp1,fp1,fp13    /* x-= TWO52;  */
-       fadd    fp1,fp1,fp13    /* x+= TWO52;  */
-       fnabs   fp1,fp1         /* if (x == 0.0) x = -0.0;  */
-       mtfsf   0x01,fp11       /* restore previous rounding mode.  */
-       blr
-
-/* The high double is > TWO52 so we need to round the low double and
-   perhaps the high double.  In this case we have to round the low
-   double and handle any adjustment to the high double that may be
-   caused by rounding (up).  This is complicated by the fact that the
-   high double may already be rounded and the low double may have the
-   opposite sign to compensate.This gets a bit tricky so we use the
-   following algorithm:
-
-   tau = floor(x_high/TWO52);
-   x0 = x_high - tau;
-   x1 = x_low + tau;
-   r1 = rint(x1);
-   y_high = x0 + r1;
-   y_low = x0 - y_high + r1;
-   return y;  */
-.L2:
-       fcmpu   cr7,fp9,fp13    /* if (|x_low| > TWO52)  */
-       fcmpu   cr0,fp9,fp12    /* || (|x_low| == 0.0)  */
-       fcmpu   cr5,fp2,fp12    /* if (x_low > 0.0)  */
-       bgelr-  cr7             /*   return x;  */
-       beqlr-  cr0
-       mtfsfi  7,1             /* Set rounding mode toward 0.  */
-       fdiv    fp8,fp1,fp13    /* x_high/TWO52  */
-
-       bng-    cr6,.L6         /* if (x > 0.0)  */
-       fctidz  fp0,fp8
-       fcfid   fp8,fp0         /* tau = floor(x_high/TWO52);  */
-       fadd    fp8,fp8,fp8     /* tau++; Make tau even  */
-       bng     cr5,.L4         /* if (x_low > 0.0)  */
-       fmr     fp3,fp1
-       fmr     fp4,fp2
-       b       .L5
-.L4:                           /* if (x_low < 0.0)  */
-       fsub    fp3,fp1,fp8     /* x0 = x_high - tau;  */
-       fadd    fp4,fp2,fp8     /* x1 = x_low + tau;  */
-.L5:
-       fadd    fp5,fp4,fp13    /* r1 = r1 + TWO52;  */
-       fsub    fp5,fp5,fp13    /* r1 = r1 - TWO52;  */
-       b       .L9
-.L6:                           /* if (x < 0.0)  */
-       fctidz  fp0,fp8
-       fcfid   fp8,fp0         /* tau = floor(x_high/TWO52);  */
-       fadd    fp8,fp8,fp8     /* tau++; Make tau even  */
-       bnl     cr5,.L7         /* if (x_low < 0.0)  */
-       fmr     fp3,fp1
-       fmr     fp4,fp2
-       b       .L8
-.L7:                           /* if (x_low > 0.0)  */
-       fsub    fp3,fp1,fp8     /* x0 = x_high - tau;  */
-       fadd    fp4,fp2,fp8     /* x1 = x_low + tau;  */
-.L8:
-       fsub    fp5,fp4,fp13    /* r1-= TWO52;  */
-       fadd    fp5,fp5,fp13    /* r1+= TWO52;  */
-.L9:
-       mtfsf   0x01,fp11       /* restore previous rounding mode.  */
-       fadd    fp1,fp3,fp5     /* y_high = x0 + r1;  */
-       fsub    fp2,fp3,fp1     /* y_low = x0 - y_high + r1;  */
-       fadd    fp2,fp2,fp5
-       blr
-END (__truncl)
-
-long_double_symbol (libm, __truncl, truncl)