[PATCH] powerpc: Fix llround spurious inexact on 32-bit POWER4 [BZ #22697]

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] powerpc: Fix llround spurious inexact on 32-bit POWER4 [BZ #22697]

Tulio Magno Quites Machado Filho
This issue is similar to BZ #19235, where spurious exceptions are
created from adding 0.5 then converting to an integer.
The solution is based on Joseph's fix for BZ #19235.

2018-01-10  Tulio Magno Quites Machado Filho  <[hidden email]>

        [BZ #22697]
        * sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S (__llround):
        Do not add 0.5 to integer or out-of-range arguments.
---
 sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S b/sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S
index d0b00ac..5ad89a1 100644
--- a/sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S
+++ b/sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S
@@ -71,6 +71,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)  */
--
2.9.5

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] powerpc: Fix llround spurious inexact on 32-bit POWER4 [BZ #22697]

Rajalakshmi Srinivasaraghavan


On 01/11/2018 04:20 AM, Tulio Magno Quites Machado Filho wrote:
> This issue is similar to BZ #19235, where spurious exceptions are
> created from adding 0.5 then converting to an integer.
> The solution is based on Joseph's fix for BZ #19235.
>
> 2018-01-10  Tulio Magno Quites Machado Filho  <[hidden email]>
>
> [BZ #22697]
> * sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S (__llround):
> Do not add 0.5 to integer or out-of-range arguments.


LGTM

>

--
Thanks
Rajalakshmi S

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] powerpc: Fix llround spurious inexact on 32-bit POWER4 [BZ #22697]

Tulio Magno Quites Machado Filho
Rajalakshmi Srinivasaraghavan <[hidden email]> writes:

> On 01/11/2018 04:20 AM, Tulio Magno Quites Machado Filho wrote:
>> This issue is similar to BZ #19235, where spurious exceptions are
>> created from adding 0.5 then converting to an integer.
>> The solution is based on Joseph's fix for BZ #19235.
>>
>> 2018-01-10  Tulio Magno Quites Machado Filho  <[hidden email]>
>>
>> [BZ #22697]
>> * sysdeps/powerpc/powerpc32/power4/fpu/s_llround.S (__llround):
>> Do not add 0.5 to integer or out-of-range arguments.
>
>
> LGTM

Pushed as af1e6be4ba60.

Thanks!

--
Tulio Magno