Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 08 Sep 2019 14:45:31 -0000
From:      "Stefan Kanthak" <stefan.kanthak@nexgo.de>
To:        <freebsd-numerics@freebsd.org>, <freebsd-hackers@freebsd.org>
Subject:   Shorter releng/12.0/lib/msun/i387/e_exp.S and releng/12.0/lib/msun/i387/s_finite.S
Message-ID:  <769CF9CBA0A34DFA92C739C970FA2AAF@H270>

next in thread | raw e-mail | index | archive | help
Hi,

here's a patch to remove a conditional branch (and more) from
http://sources.freebsd.org/releng/12.0/lib/msun/i387/e_exp.S
plus a patch to shave some bytes (immediate operands) from
http://sources.freebsd.org/releng/12.0/lib/msun/i387/s_finite.S

stay tuned
Stefan Kanthak

--- -/releng/12.0/lib/msun/i387/e_exp.S
+++ +/releng/12.0/lib/msun/i387/e_exp.S
@@ -45,7 +45,25 @@
         movl    8(%esp),%eax
-        andl    $0x7fffffff,%eax
-        cmpl    $0x7ff00000,%eax
-        jae     x_Inf_or_NaN
+        leal    (%eax+%eax),%edx
+        cmpl    $0xffe00000,%edx
+        jb      finite

+        /*
+         * Return 0 if x is -Inf.  Otherwise just return x; when x is Inf
+         * this gives Inf, and when x is a NaN this gives the same result
+         * as (x + x) (x quieted).
+         */
+        cmpl    4(%esp),$0
+        sbbl    $0xfff00000,%eax
+        je      minus_inf
+
+nan:
         fldl    4(%esp)
+        ret

+minus_inf:
+        fldz
+        ret
+
+finite:
+        fldl    4(%esp)
+
@@ -80,19 +98,3 @@
         ret
-
-x_Inf_or_NaN:
-        /*
-         * Return 0 if x is -Inf.  Otherwise just return x; when x is Inf
-         * this gives Inf, and when x is a NaN this gives the same result
-         * as (x + x) (x quieted).
-         */
-        cmpl    $0xfff00000,8(%esp)
-        jne     x_not_minus_Inf
-        cmpl    $0,4(%esp)
-        jne     x_not_minus_Inf
-        fldz
-        ret
-
-x_not_minus_Inf:
-        fldl    4(%esp)
-        ret
 END(exp)

--- -/releng/12.0/lib/msun/i387/s_finite.S
+++ +/releng/12.0/lib/msun/i387/s_finite.S
@@ -39,8 +39,8 @@
 ENTRY(finite)
         movl    8(%esp),%eax
-        andl    $0x7ff00000, %eax
-        cmpl    $0x7ff00000, %eax
+        addl    %eax, %eax
+        cmpl    $0xffe00000, %eax
         setneb  %al
-        andl    $0x000000ff, %eax
+        movzbl  %al, %eax
         ret
 END(finite)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?769CF9CBA0A34DFA92C739C970FA2AAF>