This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] PowerPC: Fix for POWER7 sinf/cosf
- From: Adhemerval Zanella <azanella at linux dot vnet dot ibm dot com>
- To: "GNU C. Library" <libc-alpha at sourceware dot org>
- Date: Tue, 29 May 2012 20:16:01 -0300
- Subject: [PATCH] PowerPC: Fix for POWER7 sinf/cosf
Fix some underflow generations for the sinf/cosf optimization for POWER7.
Tested on ppc32 and ppc64.
---
2012-05-29 Adhemerval Zanella <azanella@linux.vnet.ibm.com>
* sysdeps/powerpc/fpu/k_cosf.c: Fix underflow generation.
* sysdeps/powerpc/fpu/k_sinf.c: Likewise.
diff --git a/sysdeps/powerpc/fpu/k_cosf.c b/sysdeps/powerpc/fpu/k_cosf.c
index e2571d6..329938b 100644
--- a/sysdeps/powerpc/fpu/k_cosf.c
+++ b/sysdeps/powerpc/fpu/k_cosf.c
@@ -40,8 +40,8 @@ __kernel_cosf (float x, float y)
ix = __builtin_fabsf (x);
if (ix < twom27)
{ /* |x| < 2**-27 */
- if (x == 0.0)
- return one;
+ feraiseexcept (FE_INEXACT);
+ return one;
}
z = x * x;
r = z * (C1 + z * (C2 + z * (C3 + z * (C4 + z * (C5 + z * C6)))));
diff --git a/sysdeps/powerpc/fpu/k_sinf.c b/sysdeps/powerpc/fpu/k_sinf.c
index ab4561e..632d257 100644
--- a/sysdeps/powerpc/fpu/k_sinf.c
+++ b/sysdeps/powerpc/fpu/k_sinf.c
@@ -39,8 +39,8 @@ __kernel_sinf (float x, float y, int iy)
ix = __builtin_fabsf (x);
if (ix < twom27)
{ /* |x| < 2**-27 */
- if (x == 0.0)
- return x;
+ feraiseexcept (FE_INEXACT);
+ return x;
}
z = x * x;
v = z * x;
--
1.6.0.2
--
Adhemerval Zanella Netto
Software Engineer
Linux Technology Center Brazil
Toolchain / GLIBC on Power Architecture
azanella@linux.vnet.ibm.com / azanella@br.ibm.com
+55 61 8642-9890