about summary refs log tree commit diff
path: root/sysdeps/powerpc/powerpc64/fpu/s_llround.S
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2015-11-12 16:24:00 +0000
committerJoseph Myers <joseph@codesourcery.com>2015-11-12 16:24:00 +0000
commit32b71ad358a949cbfe16d527f9a1015b95bb9baf (patch)
tree7353a1281806cd6c5b92c40f3b6ec8be6dcfbee2 /sysdeps/powerpc/powerpc64/fpu/s_llround.S
parent1a44f1433ee4afad10eb4cb1a08d8a86b286cd40 (diff)
downloadglibc-32b71ad358a949cbfe16d527f9a1015b95bb9baf.tar.gz
glibc-32b71ad358a949cbfe16d527f9a1015b95bb9baf.tar.xz
glibc-32b71ad358a949cbfe16d527f9a1015b95bb9baf.zip
Fix powerpc64 lround, lroundf, llround, llroundf spurious "inexact" exceptions (bug 19235).
Similar to bug 19134 for powerpc32, the powerpc64 implementations of
lround, lroundf, llround, llroundf can raise spurious "inexact"
exceptions for integer arguments from adding 0.5 then converting to
integer (this does not apply to the power5+ version for double, which
uses the frin instruction which is defined never to raise "inexact"; I
don't know why power5+ doesn't use that version for float as well).

This patch fixes the bug in a similar way to the powerpc32 bug, by
testing for integers (adding and subtracting 2^52 and comparing with
the value before that addition and subtraction) and not adding 0.5 in
that case.

The powerpc maintainers may wish to look at making power5+ / power6x /
power8 use frin for float lround / llround as well as for double,
unless there's some reason I've missed that this isn't beneficial.

Tested for powerpc64.

	[BZ #19235]
	* sysdeps/powerpc/powerpc64/fpu/s_llround.S (__llround): Do not
	add 0.5 to integer arguments.
	* sysdeps/powerpc/powerpc64/fpu/s_llroundf.S (__llroundf):
	Likewise.
	(.LC2): New object.
Diffstat (limited to 'sysdeps/powerpc/powerpc64/fpu/s_llround.S')
-rw-r--r--sysdeps/powerpc/powerpc64/fpu/s_llround.S5
1 files changed, 5 insertions, 0 deletions
diff --git a/sysdeps/powerpc/powerpc64/fpu/s_llround.S b/sysdeps/powerpc/powerpc64/fpu/s_llround.S
index 321925ef56..bc433bc490 100644
--- a/sysdeps/powerpc/powerpc64/fpu/s_llround.S
+++ b/sysdeps/powerpc/powerpc64/fpu/s_llround.S
@@ -55,6 +55,11 @@ ENTRY (__llround)
 	fcmpu	cr1,fp1,fp12	/* x is negative? x < 0.0  */
 	blt-	cr6,.Lretzero	/* 0.5 > x < -0.5 so just return 0.  */
 	bge-	cr7,.Lnobias	/* 2^52 > x < -2^52 just convert with no bias.  */
+	/* Test whether an integer to avoid spurious "inexact".  */
+	fadd	fp3,fp2,fp9
+	fsub	fp3,fp3,fp9
+	fcmpu	cr5,fp2,fp3
+	beq	cr5,.Lnobias
 	fadd	fp3,fp2,fp10	/* |x|+=0.5 bias to prepare to round.  */
 	bge	cr1,.Lconvert	/* x is positive so don't negate x.  */
 	fnabs	fp3,fp3		/* -(|x|+=0.5)  */