mailing list of musl libc
 help / color / Atom feed
* Re: [updated/fixed] Patches for math subtree
@ 2019-12-10 16:56 Stefan Kanthak
  2019-12-11  9:37 ` Szabolcs Nagy
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Kanthak @ 2019-12-10 16:56 UTC (permalink / raw)
  To: musl

> Just some optimisations.

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;
-        }



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Re: [updated/fixed] Patches for math subtree
  2019-12-10 16:56 [updated/fixed] Patches for math subtree Stefan Kanthak
@ 2019-12-11  9:37 ` Szabolcs Nagy
  0 siblings, 0 replies; 2+ messages in thread
From: Szabolcs Nagy @ 2019-12-11  9:37 UTC (permalink / raw)
  To: Stefan Kanthak; +Cc: musl

* 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;
> -        }


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-10 16:56 [updated/fixed] Patches for math subtree Stefan Kanthak
2019-12-11  9:37 ` Szabolcs Nagy

mailing list of musl libc

Archives are clonable: git clone --mirror http://inbox.vuxu.org/musl

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.musl


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git