Shorter releng/12.0/lib/msun/i387/e_exp.S and releng/12.0/lib/msun/i387/s_finite.S
Stefan Kanthak
stefan.kanthak at nexgo.de
Sun Sep 8 14:45:31 UTC 2019
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)
More information about the freebsd-hackers
mailing list