Re: [updated/fixed] Patches for math subtree

Submitted by Stefan Kanthak on Dec. 10, 2019, 4:56 p.m.

Details

Message ID D107A03BFBA6431AB6778ADB104ED655@H270
State New
Series "Re: [updated/fixed] Patches for math subtree"
Headers show

Commit Message

Stefan Kanthak Dec. 10, 2019, 4:56 p.m.
> Just some optimisations.

JFTR: I'm NOT subscribed to your mailing list, so CC: me in replies!

[ Patch for remquo unchanged ]

Patch hide | download patch | download mbox

--- -/src/math/ceil.c
+++ +/src/math/ceil.c
@@ -18,10 +18,10 @@ 
+        /* special case because of non-nearest rounding modes */
+        if (e < 0x3ff) {
+                FORCE_EVAL(x + toint);
+                return u.i >> 63 ? -0.0 : 1.0;
+        }
         /* y = int(x) - x, where int(x) is an integer neighbor of x */
         if (u.i >> 63)
                 y = x - toint + toint - x;
         else
                 y = x + toint - toint - x;
-        /* special case because of non-nearest rounding modes */
-        if (e <= 0x3ff-1) {
-                FORCE_EVAL(y);
-                return u.i >> 63 ? -0.0 : 1;
-        }

--- -/src/math/floor.c
+++ +/src/math/floor.c
@@ -18,10 +18,10 @@ 
+        /* special case because of non-nearest rounding modes */
+        if (e < 0x3ff) {
+                 FORCE_EVAL(x + toint);
+                 return u.i >> 63 ? -1.0 : 0.0;
+        }
         /* y = int(x) - x, where int(x) is an integer neighbor of x */
         if (u.i >> 63)
                 y = x - toint + toint - x;
         else
                 y = x + toint - toint - x;
-        /* special case because of non-nearest rounding modes */
-        if (e <= 0x3ff-1) {
-                 FORCE_EVAL(y);
-                 return u.i >> 63 ? -1 : 0;
-        }

Comments

Szabolcs Nagy Dec. 11, 2019, 9:37 a.m.
* Stefan Kanthak <stefan.kanthak@nexgo.de> [2019-12-10 17:56:51 +0100]:
> > Just some optimisations.

thanks for the patches.

i think optimizing |x|<1 is not very important.

c99 allowed 2 fenv behaviours, we (and fdlibm) choose
one, c2x went with the other: no inexact exception is
allowed.

so if i touch this code i would rewrite it with int
arithmetics (which will be slower on most hard float
targets than the current code anyway)

> 
> JFTR: I'm NOT subscribed to your mailing list, so CC: me in replies!
> 
> [ Patch for remquo unchanged ]
> 
> --- -/src/math/ceil.c
> +++ +/src/math/ceil.c
> @@ -18,10 +18,10 @@
> +        /* special case because of non-nearest rounding modes */
> +        if (e < 0x3ff) {
> +                FORCE_EVAL(x + toint);
> +                return u.i >> 63 ? -0.0 : 1.0;
> +        }
>          /* y = int(x) - x, where int(x) is an integer neighbor of x */
>          if (u.i >> 63)
>                  y = x - toint + toint - x;
>          else
>                  y = x + toint - toint - x;
> -        /* special case because of non-nearest rounding modes */
> -        if (e <= 0x3ff-1) {
> -                FORCE_EVAL(y);
> -                return u.i >> 63 ? -0.0 : 1;
> -        }
> 
> --- -/src/math/floor.c
> +++ +/src/math/floor.c
> @@ -18,10 +18,10 @@
> +        /* special case because of non-nearest rounding modes */
> +        if (e < 0x3ff) {
> +                 FORCE_EVAL(x + toint);
> +                 return u.i >> 63 ? -1.0 : 0.0;
> +        }
>          /* y = int(x) - x, where int(x) is an integer neighbor of x */
>          if (u.i >> 63)
>                  y = x - toint + toint - x;
>          else
>                  y = x + toint - toint - x;
> -        /* special case because of non-nearest rounding modes */
> -        if (e <= 0x3ff-1) {
> -                 FORCE_EVAL(y);
> -                 return u.i >> 63 ? -1 : 0;
> -        }