]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Do not raise "inexact" from powerpc64 ceil, floor, trunc (bug 15479).
authorJoseph Myers <joseph@codesourcery.com>
Wed, 25 May 2016 17:42:22 +0000 (17:42 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Wed, 25 May 2016 17:42:22 +0000 (17:42 +0000)
Continuing fixes for ceil, floor and trunc functions not to raise the
"inexact" exception, this patch fixes the versions used on older
powerpc64 processors.  As was done with the round implementations some
time ago, the save of floating-point state is moved after the first
floating-point operation on the input to ensure that any "invalid"
exception from signaling NaN input is included in the saved state, and
then the whole state gets restored rather than just the rounding mode.

This has no effect on configurations using the power5+ code, since
such processors can do these operations with a single instruction (and
those instructions do not set "inexact", so are correct for TS 18661-1
semantics).

Tested for powerpc64.

[BZ #15479]
* sysdeps/powerpc/powerpc64/fpu/s_ceil.S (__ceil): Move save of
floating-point state after first floating-point operation on
input.  Restore full floating-point state instead of just rounding
mode.
* sysdeps/powerpc/powerpc64/fpu/s_ceilf.S (__ceilf): Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_floor.S (__floor): Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_floorf.S (__floorf): Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_trunc.S (__trunc): Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_truncf.S (__truncf): Likewise.

ChangeLog
sysdeps/powerpc/powerpc64/fpu/s_ceil.S
sysdeps/powerpc/powerpc64/fpu/s_ceilf.S
sysdeps/powerpc/powerpc64/fpu/s_floor.S
sysdeps/powerpc/powerpc64/fpu/s_floorf.S
sysdeps/powerpc/powerpc64/fpu/s_trunc.S
sysdeps/powerpc/powerpc64/fpu/s_truncf.S

index 456457180945cae872a9f040100179ec390698b2..89c2a9c0f5876d29667ff8f1994422d0a285f0cb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2016-05-25  Joseph Myers  <joseph@codesourcery.com>
 
+       [BZ #15479]
+       * sysdeps/powerpc/powerpc64/fpu/s_ceil.S (__ceil): Move save of
+       floating-point state after first floating-point operation on
+       input.  Restore full floating-point state instead of just rounding
+       mode.
+       * sysdeps/powerpc/powerpc64/fpu/s_ceilf.S (__ceilf): Likewise.
+       * sysdeps/powerpc/powerpc64/fpu/s_floor.S (__floor): Likewise.
+       * sysdeps/powerpc/powerpc64/fpu/s_floorf.S (__floorf): Likewise.
+       * sysdeps/powerpc/powerpc64/fpu/s_trunc.S (__trunc): Likewise.
+       * sysdeps/powerpc/powerpc64/fpu/s_truncf.S (__truncf): Likewise.
+
        [BZ #15479]
        * sysdeps/powerpc/powerpc32/fpu/s_ceil.S (__ceil): Move save of
        floating-point state after first floating-point operation on
index 77fe0f3c962e9b73110df543a97e0038883306eb..d2f96bb628d6dc68ea3c6ca92fc8fb7746975f83 100644 (file)
 
 EALIGN (__ceil, 4, 0)
        CALL_MCOUNT 0
-       mffs    fp11            /* Save current FPU rounding mode.  */
        lfd     fp13,.LC0@toc(2)
        fabs    fp0,fp1
        fsub    fp12,fp13,fp13  /* generate 0.0  */
        fcmpu   cr7,fp0,fp13    /* if (fabs(x) > TWO52)  */
+       mffs    fp11            /* Save current FPU rounding mode and
+                                  "inexact" state.  */
        fcmpu   cr6,fp1,fp12    /* if (x > 0.0)  */
        bnllr-  cr7
        mtfsfi  7,2             /* Set rounding mode toward +inf.  */
@@ -39,7 +40,8 @@ EALIGN (__ceil, 4, 0)
        fsub    fp1,fp1,fp13    /* x-= TWO52;  */
        fabs    fp1,fp1         /* if (x == 0.0)  */
                                /* x = 0.0; */
-       mtfsf   0x01,fp11       /* restore previous rounding mode.  */
+       mtfsf   0xff,fp11       /* Restore previous rounding mode and
+                                  "inexact" state.  */
        blr
 .L4:
        bge-    cr6,.L9         /* if (x < 0.0)  */
@@ -48,7 +50,8 @@ EALIGN (__ceil, 4, 0)
        fnabs   fp1,fp1         /* if (x == 0.0)  */
                                /* x = -0.0; */
 .L9:
-       mtfsf   0x01,fp11       /* restore previous rounding mode.  */
+       mtfsf   0xff,fp11       /* Restore previous rounding mode and
+                                  "inexact" state.  */
        blr
        END (__ceil)
 
index 91d4a25ae155c8faf4b5930ea5b30ce9957f3c26..ed944912a96721080344fd89269c0f8c946b7553 100644 (file)
 
 EALIGN (__ceilf, 4, 0)
        CALL_MCOUNT 0
-       mffs    fp11            /* Save current FPU rounding mode.  */
        lfs     fp13,.LC0@toc(2)
        fabs    fp0,fp1
        fsubs   fp12,fp13,fp13  /* generate 0.0  */
        fcmpu   cr7,fp0,fp13    /* if (fabs(x) > TWO23)  */
+       mffs    fp11            /* Save current FPU rounding mode and
+                                  "inexact" state.  */
        fcmpu   cr6,fp1,fp12    /* if (x > 0.0)  */
        bnllr-  cr7
        mtfsfi  7,2             /* Set rounding mode toward +inf.  */
@@ -40,7 +41,8 @@ EALIGN (__ceilf, 4, 0)
        fsubs   fp1,fp1,fp13    /* x-= TWO23;  */
        fabs    fp1,fp1         /* if (x == 0.0)  */
                                /* x = 0.0; */
-       mtfsf   0x01,fp11       /* restore previous rounding mode.  */
+       mtfsf   0xff,fp11       /* Restore previous rounding mode and
+                                  "inexact" state.  */
        blr
 .L4:
        bge-    cr6,.L9         /* if (x < 0.0)  */
@@ -49,7 +51,8 @@ EALIGN (__ceilf, 4, 0)
        fnabs   fp1,fp1         /* if (x == 0.0)  */
                                /* x = -0.0; */
 .L9:
-       mtfsf   0x01,fp11       /* restore previous rounding mode.  */
+       mtfsf   0xff,fp11       /* Restore previous rounding mode and
+                                  "inexact" state.  */
        blr
        END (__ceilf)
 
index afa08b70c425b284ca1571299e3bc1ffb771fe4b..a3047524239369a445b49ada1fcf7cc67b645997 100644 (file)
 
 EALIGN (__floor, 4, 0)
        CALL_MCOUNT 0
-       mffs    fp11            /* Save current FPU rounding mode.  */
        lfd     fp13,.LC0@toc(2)
        fabs    fp0,fp1
        fsub    fp12,fp13,fp13  /* generate 0.0  */
        fcmpu   cr7,fp0,fp13    /* if (fabs(x) > TWO52)  */
+       mffs    fp11            /* Save current FPU rounding mode and
+                                  "inexact" state.  */
        fcmpu   cr6,fp1,fp12    /* if (x > 0.0)  */
        bnllr-  cr7
        mtfsfi  7,3             /* Set rounding mode toward -inf.  */
@@ -39,7 +40,8 @@ EALIGN (__floor, 4, 0)
        fsub    fp1,fp1,fp13    /* x-= TWO52;  */
        fabs    fp1,fp1         /* if (x == 0.0)  */
                                /* x = 0.0; */
-       mtfsf   0x01,fp11       /* restore previous rounding mode.  */
+       mtfsf   0xff,fp11       /* Restore previous rounding mode and
+                                  "inexact" state.  */
        blr
 .L4:
        bge-    cr6,.L9         /* if (x < 0.0)  */
@@ -48,7 +50,8 @@ EALIGN (__floor, 4, 0)
        fnabs   fp1,fp1         /* if (x == 0.0)  */
                                /* x = -0.0; */
 .L9:
-       mtfsf   0x01,fp11       /* restore previous rounding mode.  */
+       mtfsf   0xff,fp11       /* Restore previous rounding mode and
+                                  "inexact" state.  */
        blr
        END (__floor)
 
index 80080ca0b6aafe36ad5723a965fabf65aea8bd67..24e76b056825e254debfd7190f51b21dcf36d78f 100644 (file)
 
 EALIGN (__floorf, 4, 0)
        CALL_MCOUNT 0
-       mffs    fp11            /* Save current FPU rounding mode.  */
        lfs     fp13,.LC0@toc(2)
        fabs    fp0,fp1
        fsubs   fp12,fp13,fp13  /* generate 0.0  */
        fcmpu   cr7,fp0,fp13    /* if (fabs(x) > TWO23)  */
+       mffs    fp11            /* Save current FPU rounding mode and
+                                  "inexact" state.  */
        fcmpu   cr6,fp1,fp12    /* if (x > 0.0)  */
        bnllr-  cr7
        mtfsfi  7,3             /* Set rounding mode toward -inf.  */
@@ -40,7 +41,8 @@ EALIGN (__floorf, 4, 0)
        fsubs   fp1,fp1,fp13    /* x-= TWO23;  */
        fabs    fp1,fp1         /* if (x == 0.0)  */
                                /* x = 0.0; */
-       mtfsf   0x01,fp11       /* restore previous rounding mode.  */
+       mtfsf   0xff,fp11       /* Restore previous rounding mode and
+                                  "inexact" state.  */
        blr
 .L4:
        bge-    cr6,.L9         /* if (x < 0.0)  */
@@ -49,7 +51,8 @@ EALIGN (__floorf, 4, 0)
        fnabs   fp1,fp1         /* if (x == 0.0)  */
                                /* x = -0.0; */
 .L9:
-       mtfsf   0x01,fp11       /* restore previous rounding mode.  */
+       mtfsf   0xff,fp11       /* Restore previous rounding mode and
+                                  "inexact" state.  */
        blr
        END (__floorf)
 
index 4ad939ebc4681a030adb3b2d94ed1fd0fb511c99..f310c317c3330b48721945293796bb65d1998359 100644 (file)
 
 EALIGN (__trunc, 4, 0)
        CALL_MCOUNT 0
-       mffs    fp11            /* Save current FPU rounding mode.  */
        lfd     fp13,.LC0@toc(2)
        fabs    fp0,fp1
        fsub    fp12,fp13,fp13  /* generate 0.0  */
        fcmpu   cr7,fp0,fp13    /* if (fabs(x) > TWO52)  */
+       mffs    fp11            /* Save current FPU rounding mode and
+                                  "inexact" state.  */
        fcmpu   cr6,fp1,fp12    /* if (x > 0.0)  */
        bnllr-  cr7
        mtfsfi  7,1             /* Set rounding toward 0 mode.  */
@@ -46,7 +47,8 @@ EALIGN (__trunc, 4, 0)
        fsub    fp1,fp1,fp13    /* x-= TWO52;  */
        fabs    fp1,fp1         /* if (x == 0.0)  */
                                /* x = 0.0; */
-       mtfsf   0x01,fp11       /* restore previous rounding mode.  */
+       mtfsf   0xff,fp11       /* Restore previous rounding mode and
+                                  "inexact" state.  */
        blr
 .L4:
        bge-    cr6,.L9         /* if (x < 0.0)  */
@@ -55,7 +57,8 @@ EALIGN (__trunc, 4, 0)
        fnabs   fp1,fp1         /* if (x == 0.0)  */
                                /* x = -0.0; */
 .L9:
-       mtfsf   0x01,fp11       /* restore previous rounding mode.  */
+       mtfsf   0xff,fp11       /* Restore previous rounding mode and
+                                  "inexact" state.  */
        blr
        END (__trunc)
 
index 3a990550d6394312baef6402321027cb2991c0dc..b4fce645cd693c1221c7f41745b0b28cba712b68 100644 (file)
 
 EALIGN (__truncf, 4, 0)
        CALL_MCOUNT 0
-       mffs    fp11            /* Save current FPU rounding mode.  */
        lfs     fp13,.LC0@toc(2)
        fabs    fp0,fp1
        fsubs   fp12,fp13,fp13  /* generate 0.0  */
        fcmpu   cr7,fp0,fp13    /* if (fabs(x) > TWO23)  */
+       mffs    fp11            /* Save current FPU rounding mode and
+                                  "inexact" state.  */
        fcmpu   cr6,fp1,fp12    /* if (x > 0.0)  */
        bnllr-  cr7
        mtfsfi  7,1             /* Set rounding toward 0 mode.  */
@@ -47,7 +48,8 @@ EALIGN (__truncf, 4, 0)
        fsubs   fp1,fp1,fp13    /* x-= TWO23;  */
        fabs    fp1,fp1         /* if (x == 0.0)  */
                                /* x = 0.0; */
-       mtfsf   0x01,fp11       /* restore previous rounding mode.  */
+       mtfsf   0xff,fp11       /* Restore previous rounding mode and
+                                  "inexact" state.  */
        blr
 .L4:
        bge-    cr6,.L9         /* if (x < 0.0)  */
@@ -56,7 +58,8 @@ EALIGN (__truncf, 4, 0)
        fnabs   fp1,fp1         /* if (x == 0.0)  */
                                /* x = -0.0; */
 .L9:
-       mtfsf   0x01,fp11       /* restore previous rounding mode.  */
+       mtfsf   0xff,fp11       /* Restore previous rounding mode and
+                                  "inexact" state.  */
        blr
        END (__truncf)