]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
math: Remove i386 ilogb/ilogbf/llogb/llogbf
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 28 Apr 2025 19:54:49 +0000 (16:54 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 2 Jun 2025 16:32:19 +0000 (13:32 -0300)
The new float and double implementation does not required an
extra function call and error handling uses math_err function,
which results in better performance on i386 as well.

With gcc-14 on AMD AMD Ryzen 9 5900X, master shows:

$ ./benchtests/bench-ilogb
  "ilogb": {
   "subnormal": {
    "duration": 3.68863e+09,
    "iterations": 1.72228e+08,
    "max": 89.2995,
    "min": 21.016,
    "mean": 21.4171
   },
   "normal": {
    "duration": 3.68878e+09,
    "iterations": 1.72948e+08,
    "max": 78.6065,
    "min": 21.127,
    "mean": 21.3288
   }
  }
$ ./benchtests/bench-ilogbf
  "ilogbf": {
   "subnormal": {
    "duration": 3.68835e+09,
    "iterations": 1.66716e+08,
    "max": 46.953,
    "min": 21.793,
    "mean": 22.1236
   },
   "normal": {
    "duration": 3.68784e+09,
    "iterations": 1.66168e+08,
    "max": 46.9715,
    "min": 21.904,
    "mean": 22.1935
   }
  }

While with this patch:

$ ./benchtests/bench-ilogb
  "ilogb": {
   "subnormal": {
    "duration": 3.68134e+09,
    "iterations": 4.17516e+08,
    "max": 32.5045,
    "min": 8.3245,
    "mean": 8.81723
   },
   "normal": {
    "duration": 3.6677e+09,
    "iterations": 6.79468e+08,
    "max": 50.9305,
    "min": 5.3465,
    "mean": 5.3979
   }
}
$ ./benchtests/bench-ilogbf
  "ilogbf": {
   "subnormal": {
    "duration": 3.67553e+09,
    "iterations": 5.11032e+08,
    "max": 35.927,
    "min": 7.0485,
    "mean": 7.19237
   },
   "normal": {
    "duration": 3.66877e+09,
    "iterations": 6.556e+08,
    "max": 26.3625,
    "min": 5.5315,
    "mean": 5.59605
   }
 }

Checked on i686-linux-gnu.

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
sysdeps/i386/fpu/e_ilogb.S [deleted file]
sysdeps/i386/fpu/e_ilogbf.S [deleted file]
sysdeps/i386/fpu/w_ilogb.c [deleted file]
sysdeps/i386/fpu/w_ilogbf.c [deleted file]
sysdeps/i386/fpu/w_llogb.c [deleted file]
sysdeps/i386/fpu/w_llogbf.c [deleted file]

diff --git a/sysdeps/i386/fpu/e_ilogb.S b/sysdeps/i386/fpu/e_ilogb.S
deleted file mode 100644 (file)
index f4b792c..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Public domain.
- */
-
-#include <machine/asm.h>
-
-RCSID("$NetBSD: s_ilogb.S,v 1.5 1995/10/12 15:53:09 jtc Exp $")
-
-ENTRY(__ieee754_ilogb)
-       fldl    4(%esp)
-/* I added the following ugly construct because ilogb(+-Inf) is
-   required to return INT_MAX in ISO C99.
-   -- jakub@redhat.com.  */
-       fxam                    /* Is NaN or +-Inf?  */
-       fstsw   %ax
-       movb    $0x45, %dh
-       andb    %ah, %dh
-       cmpb    $0x05, %dh
-       je      1f              /* Is +-Inf, jump.  */
-       cmpb    $0x40, %dh
-       je      2f              /* Is +-0, jump.  */
-
-       fxtract
-       pushl   %eax
-       cfi_adjust_cfa_offset (4)
-       fstp    %st
-
-       fistpl  (%esp)
-       fwait
-       popl    %eax
-       cfi_adjust_cfa_offset (-4)
-
-       ret
-
-1:     fstp    %st
-       movl    $0x7fffffff, %eax
-       ret
-2:     fstp    %st
-       movl    $0x80000000, %eax       /* FP_ILOGB0  */
-       ret
-END (__ieee754_ilogb)
diff --git a/sysdeps/i386/fpu/e_ilogbf.S b/sysdeps/i386/fpu/e_ilogbf.S
deleted file mode 100644 (file)
index 37298b9..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Public domain.
- */
-
-#include <machine/asm.h>
-
-RCSID("$NetBSD: s_ilogbf.S,v 1.4 1995/10/22 20:32:43 pk Exp $")
-
-ENTRY(__ieee754_ilogbf)
-       flds    4(%esp)
-/* I added the following ugly construct because ilogb(+-Inf) is
-   required to return INT_MAX in ISO C99.
-   -- jakub@redhat.com.  */
-       fxam                    /* Is NaN or +-Inf?  */
-       fstsw   %ax
-       movb    $0x45, %dh
-       andb    %ah, %dh
-       cmpb    $0x05, %dh
-       je      1f              /* Is +-Inf, jump.  */
-       cmpb    $0x40, %dh
-       je      2f              /* Is +-0, jump.  */
-
-       fxtract
-       pushl   %eax
-       cfi_adjust_cfa_offset (4)
-       fstp    %st
-
-       fistpl  (%esp)
-       fwait
-       popl    %eax
-       cfi_adjust_cfa_offset (-4)
-
-       ret
-
-1:     fstp    %st
-       movl    $0x7fffffff, %eax
-       ret
-2:     fstp    %st
-       movl    $0x80000000, %eax       /* FP_ILOGB0  */
-       ret
-END (__ieee754_ilogbf)
diff --git a/sysdeps/i386/fpu/w_ilogb.c b/sysdeps/i386/fpu/w_ilogb.c
deleted file mode 100644 (file)
index 9c26217..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#include <math-type-macros-double.h>
-#include <w_ilogb_template.c>
diff --git a/sysdeps/i386/fpu/w_ilogbf.c b/sysdeps/i386/fpu/w_ilogbf.c
deleted file mode 100644 (file)
index 047ad4b..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#include <math-type-macros-float.h>
-#include <w_ilogb_template.c>
diff --git a/sysdeps/i386/fpu/w_llogb.c b/sysdeps/i386/fpu/w_llogb.c
deleted file mode 100644 (file)
index 5e8891a..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#include <math-type-macros-double.h>
-#include <w_llogb_template.c>
diff --git a/sysdeps/i386/fpu/w_llogbf.c b/sysdeps/i386/fpu/w_llogbf.c
deleted file mode 100644 (file)
index edb7e9a..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#include <math-type-macros-float.h>
-#include <w_llogb_template.c>