olga / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1457177-1.patch

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