Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Sep 2019 12:45:03 +0200
From:      "Stefan Kanthak" <stefan.kanthak@nexgo.de>
To:        <freebsd-numerics@freebsd.org>
Cc:        <das@FreeBSD.ORG>
Subject:   Superfluous instructions in crufty old releng/12.0/lib/msun/i387/s_remquo.S, releng/12.0/lib/msun/amd64/s_remquo.S, ...
Message-ID:  <582553CAF6B647A09A15C24F50B9A75E@H270>

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

Hi,

although I doubt that this FPU code might still be used,
here's a patch to shave 2 superfluous instructions from
http://sources.freebsd.org/releng/12.0/lib/msun/i387/s_remquo.S
http://sources.freebsd.org/releng/12.0/lib/msun/i387/s_remquof.S
http://sources.freebsd.org/releng/12.0/lib/msun/i387/s_remquol.S
http://sources.freebsd.org/releng/12.0/lib/msun/amd64/s_remquo.S
http://sources.freebsd.org/releng/12.0/lib/msun/amd64/s_remquof.S
http://sources.freebsd.org/releng/12.0/lib/msun/amd64/s_remquol.S

regards
Stefan Kanthak

--- -/releng/12.0/lib/msun/i387/s_remquo.S
+++ +/releng/12.0/lib/msun/i387/s_remquo.S
@@ -51,8 +51,6 @@
 /* Negate the quotient bits if x*y<0.  Avoid using an unpredictable branch. */
         movl    16(%esp),%ecx
         xorl    8(%esp),%ecx
-        sarl    $16,%ecx
-        sarl    $16,%ecx
+        sarl    $31,%ecx
         xorl    %ecx,%eax
-        andl    $1,%ecx
-        addl    %ecx,%eax
+        subl    %ecx,%eax

--- -/releng/12.0/lib/msun/i387/s_remquof.S
+++ +/releng/12.0/lib/msun/i387/s_remquof.S
@@ -51,8 +51,6 @@
 /* Negate the quotient bits if x*y<0.  Avoid using an unpredictable branch. */
         movl    8(%esp),%ecx
         xorl    4(%esp),%ecx
-        sarl    $16,%ecx
-        sarl    $16,%ecx
+        sarl    $31,%ecx
         xorl    %ecx,%eax
-        andl    $1,%ecx
-        addl    %ecx,%eax
+        subl    %ecx,%eax

--- -/releng/12.0/lib/msun/i387/s_remquol.S
+++ +/releng/12.0/lib/msun/i387/s_remquol.S
@@ -51,9 +51,7 @@
 /* Negate the quotient bits if x*y<0.  Avoid using an unpredictable branch. */
         movl    24(%esp),%ecx
         xorl    12(%esp),%ecx
         movsx   %cx,%ecx
         sarl    $16,%ecx
-        sarl    $16,%ecx
         xorl    %ecx,%eax
-        andl    $1,%ecx
-        addl    %ecx,%eax
+        subl    %ecx,%eax

--- -/releng/12.0/lib/msun/amd64/s_remquo.S
--- +/releng/12.0/lib/msun/amd64/s_remquo.S
@@ -53,8 +53,6 @@
 /* Negate the quotient bits if x*y<0.  Avoid using an unpredictable branch. */
         movl    -12(%rsp),%ecx
         xorl    -4(%rsp),%ecx
-        sarl    $16,%ecx
-        sarl    $16,%ecx
+        sarl    $31,%ecx
         xorl    %ecx,%eax
-        andl    $1,%ecx
-        addl    %ecx,%eax
+        subl    %ecx,%eax

--- -/releng/12.0/lib/msun/amd64/s_remquof.S
--- +/releng/12.0/lib/msun/amd64/s_remquof.S
@@ -53,8 +53,6 @@
 /* Negate the quotient bits if x*y<0.  Avoid using an unpredictable branch. */
         movl    -8(%rsp),%ecx
         xorl    -4(%rsp),%ecx
-        sarl    $16,%ecx
-        sarl    $16,%ecx
+        sarl    $31,%ecx
         xorl    %ecx,%eax
-        andl    $1,%ecx
-        addl    %ecx,%eax
+        subl    %ecx,%eax

--- -/releng/12.0/lib/msun/amd64/s_remquol.S
--- +/releng/12.0/lib/msun/amd64/s_remquol.S
@@ -51,9 +51,6 @@
 /* Negate the quotient bits if x*y<0.  Avoid using an unpredictable branch. */
         movl    32(%rsp),%ecx
         xorl    16(%rsp),%ecx
         movsx   %cx,%ecx
         sarl    $16,%ecx
-        sarl    $16,%ecx
         xorl    %ecx,%eax
-        andl    $1,%ecx
-        addl    %ecx,%eax
+        subl    %ecx,%eax



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