[PATCH 13/13] x86_64: Remove the AVX variants of sin, cos, tan, and sincos

Adhemerval Zanella adhemerval.zanella@linaro.org
Tue Nov 17 20:46:51 GMT 2026


With the CORE-MATH implementations, the AVX variants (-mavx, for CPUs
with AVX but without FMA) only gain the inline roundsd, while the
software fma calls dominate the cost: their reciprocal throughput ranges
from 3% better (tan) to 6% worse (cos) than the SSE2 variants, 0.1%
worse in geometric mean.  The sincos one was not even selected, since
sincos uses ifunc-fma4.h.

Reciprocal throughput (ns) of each variant, selected with
glibc.cpu.hwcaps on a Ryzen 9 5900X:

                    sse2         avx         fma
sin     fast       98.89       97.68       18.53
        moderate   99.84       99.08       18.27
        slow       86.22       86.30       28.46
cos     fast      100.96      107.43       17.95
        moderate   99.08      104.60       17.43
        slow       95.46       94.07       27.62
tan     fast      875.34      863.31       45.70
        moderate  861.05      834.22       60.35
        slow      870.65      843.40       69.90

Use ifunc-fma4.h for sin, cos, and tan, which keeps the FMA and FMA4
variants.  libm.so .text shrinks by 21952 bytes.
---
 sysdeps/x86_64/fpu/multiarch/Makefile       | 8 --------
 sysdeps/x86_64/fpu/multiarch/s_cos-avx.c    | 4 ----
 sysdeps/x86_64/fpu/multiarch/s_cos.c        | 2 +-
 sysdeps/x86_64/fpu/multiarch/s_sin-avx.c    | 4 ----
 sysdeps/x86_64/fpu/multiarch/s_sin.c        | 2 +-
 sysdeps/x86_64/fpu/multiarch/s_sincos-avx.c | 3 ---
 sysdeps/x86_64/fpu/multiarch/s_tan-avx.c    | 4 ----
 sysdeps/x86_64/fpu/multiarch/s_tan.c        | 2 +-
 8 files changed, 3 insertions(+), 26 deletions(-)
 delete mode 100644 sysdeps/x86_64/fpu/multiarch/s_cos-avx.c
 delete mode 100644 sysdeps/x86_64/fpu/multiarch/s_sin-avx.c
 delete mode 100644 sysdeps/x86_64/fpu/multiarch/s_sincos-avx.c
 delete mode 100644 sysdeps/x86_64/fpu/multiarch/s_tan-avx.c

diff --git a/sysdeps/x86_64/fpu/multiarch/Makefile b/sysdeps/x86_64/fpu/multiarch/Makefile
index 3bef32fd32d..0ad12ae2669 100644
--- a/sysdeps/x86_64/fpu/multiarch/Makefile
+++ b/sysdeps/x86_64/fpu/multiarch/Makefile
@@ -93,7 +93,6 @@ libm-sysdep_routines += \
   s_atan-fma \
   s_ceil-sse4_1 \
   s_ceilf-sse4_1 \
-  s_cos-avx \
   s_cos-fma \
   s_cosf-fma \
   s_cosf-sse2 \
@@ -109,15 +108,12 @@ libm-sysdep_routines += \
   s_rintf-sse4_1 \
   s_roundeven-sse4_1 \
   s_roundevenf-sse4_1 \
-  s_sin-avx \
   s_sin-fma \
-  s_sincos-avx \
   s_sincos-fma \
   s_sincosf-fma \
   s_sincosf-sse2 \
   s_sinf-fma \
   s_sinf-sse2 \
-  s_tan-avx \
   s_tan-fma \
   s_tanh-fma \
   s_trunc-sse4_1 \
@@ -161,10 +157,6 @@ CFLAGS-e_atan2-avx.c = -mavx
 CFLAGS-e_exp-avx.c = -mavx
 CFLAGS-e_log-avx.c = -mavx
 CFLAGS-s_atan-avx.c = -mavx
-CFLAGS-s_cos-avx.c = -mavx
-CFLAGS-s_sin-avx.c = -mavx
-CFLAGS-s_tan-avx.c = -mavx
-CFLAGS-s_sincos-avx.c = -mavx
 
 CFLAGS-s_modf-sse4_1.c = -msse4.1 -fno-builtin-modff32x -fno-builtin-modff64
 CFLAGS-s_modff-sse4_1.c = -msse4.1 -fno-builtin-modff32
diff --git a/sysdeps/x86_64/fpu/multiarch/s_cos-avx.c b/sysdeps/x86_64/fpu/multiarch/s_cos-avx.c
deleted file mode 100644
index 3c3eb8e3efb..00000000000
--- a/sysdeps/x86_64/fpu/multiarch/s_cos-avx.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#define __cos __cos_avx
-#define SECTION __attribute__ ((section (".text.avx")))
-
-#include <sysdeps/ieee754/dbl-64/s_cos.c>
diff --git a/sysdeps/x86_64/fpu/multiarch/s_cos.c b/sysdeps/x86_64/fpu/multiarch/s_cos.c
index 2e4ecbc22ce..1605af5928a 100644
--- a/sysdeps/x86_64/fpu/multiarch/s_cos.c
+++ b/sysdeps/x86_64/fpu/multiarch/s_cos.c
@@ -23,7 +23,7 @@
 extern double __redirect_cos (double);
 
 # define SYMBOL_NAME cos
-# include "ifunc-avx-fma4.h"
+# include "ifunc-fma4.h"
 
 libc_ifunc_redirected (__redirect_cos, __cos, IFUNC_SELECTOR ());
 libm_alias_double (__cos, cos)
diff --git a/sysdeps/x86_64/fpu/multiarch/s_sin-avx.c b/sysdeps/x86_64/fpu/multiarch/s_sin-avx.c
deleted file mode 100644
index 651943456f3..00000000000
--- a/sysdeps/x86_64/fpu/multiarch/s_sin-avx.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#define __sin __sin_avx
-#define SECTION __attribute__ ((section (".text.avx")))
-
-#include <sysdeps/ieee754/dbl-64/s_sin.c>
diff --git a/sysdeps/x86_64/fpu/multiarch/s_sin.c b/sysdeps/x86_64/fpu/multiarch/s_sin.c
index c8cfb96b77d..a75db4607ce 100644
--- a/sysdeps/x86_64/fpu/multiarch/s_sin.c
+++ b/sysdeps/x86_64/fpu/multiarch/s_sin.c
@@ -23,7 +23,7 @@
 extern double __redirect_sin (double);
 
 # define SYMBOL_NAME sin
-# include "ifunc-avx-fma4.h"
+# include "ifunc-fma4.h"
 
 libc_ifunc_redirected (__redirect_sin, __sin, IFUNC_SELECTOR ());
 libm_alias_double (__sin, sin)
diff --git a/sysdeps/x86_64/fpu/multiarch/s_sincos-avx.c b/sysdeps/x86_64/fpu/multiarch/s_sincos-avx.c
deleted file mode 100644
index debea0f619a..00000000000
--- a/sysdeps/x86_64/fpu/multiarch/s_sincos-avx.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#define __sincos __sincos_avx
-#define SECTION __attribute__ ((section (".text.avx")))
-#include <sysdeps/ieee754/dbl-64/s_sincos.c>
diff --git a/sysdeps/x86_64/fpu/multiarch/s_tan-avx.c b/sysdeps/x86_64/fpu/multiarch/s_tan-avx.c
deleted file mode 100644
index 3ca3af2ca37..00000000000
--- a/sysdeps/x86_64/fpu/multiarch/s_tan-avx.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#define __tan __tan_avx
-#define SECTION __attribute__ ((section (".text.avx")))
-
-#include <sysdeps/ieee754/dbl-64/s_tan.c>
diff --git a/sysdeps/x86_64/fpu/multiarch/s_tan.c b/sysdeps/x86_64/fpu/multiarch/s_tan.c
index 77976471d6c..b227ea08e27 100644
--- a/sysdeps/x86_64/fpu/multiarch/s_tan.c
+++ b/sysdeps/x86_64/fpu/multiarch/s_tan.c
@@ -23,7 +23,7 @@
 extern double __redirect_tan (double);
 
 # define SYMBOL_NAME tan
-# include "ifunc-avx-fma4.h"
+# include "ifunc-fma4.h"
 
 libc_ifunc_redirected (__redirect_tan, __tan, IFUNC_SELECTOR ());
 libm_alias_double (__tan, tan)
-- 
2.53.0



More information about the Libc-alpha mailing list