194 lines
5.5 KiB
Diff
194 lines
5.5 KiB
Diff
commit 7ecf0d3bde54e4f9e6f025d2f43eff565ed97414
|
|
Author: H.J. Lu <hjl.tools@gmail.com>
|
|
Date: Thu Apr 4 15:43:50 2024 -0700
|
|
|
|
x86-64: Exclude FMA4 IFUNC functions for -mapxf
|
|
|
|
When -mapxf is used to build glibc, the resulting glibc will never run
|
|
on FMA4 machines. Exclude FMA4 IFUNC functions when -mapxf is used.
|
|
This requires GCC which defines __APX_F__ for -mapxf with commit:
|
|
|
|
1df56719bd8 x86: Define __APX_F__ for -mapxf
|
|
|
|
Reviewed-by: Sunil K Pandey <skpgkp2@gmail.com>
|
|
(cherry picked from commit 9e1f4aef865ddeffeb4b5f6578fefab606783120)
|
|
|
|
diff --git a/config.h.in b/config.h.in
|
|
index 1e647de58580bc2d..a5fdea0c3c7b070e 100644
|
|
--- a/config.h.in
|
|
+++ b/config.h.in
|
|
@@ -295,4 +295,7 @@
|
|
/* Define if -mmovbe is enabled by default on x86. */
|
|
#undef HAVE_X86_MOVBE
|
|
|
|
+/* Define if -mapxf is enabled by default on x86. */
|
|
+#undef HAVE_X86_APX
|
|
+
|
|
#endif
|
|
diff --git a/sysdeps/x86_64/configure b/sysdeps/x86_64/configure
|
|
index 04a534fa126a7bf7..07bdd40a37247c7b 100755
|
|
--- a/sysdeps/x86_64/configure
|
|
+++ b/sysdeps/x86_64/configure
|
|
@@ -162,6 +162,38 @@ printf "%s\n" "$libc_cv_x86_have_amx_tile" >&6; }
|
|
config_vars="$config_vars
|
|
have-mamx-tile = $libc_cv_x86_have_amx_tile"
|
|
|
|
+# Check if -mapxf is enabled.
|
|
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -mapxf is enabled" >&5
|
|
+printf %s "checking whether -mapxf is enabled... " >&6; }
|
|
+if test ${libc_cv_x86_have_apx+y}
|
|
+then :
|
|
+ printf %s "(cached) " >&6
|
|
+else $as_nop
|
|
+ cat > conftest.c <<EOF
|
|
+#ifndef __APX_F__
|
|
+# error APX isn't enabled
|
|
+#endif
|
|
+EOF
|
|
+ libc_cv_x86_have_apx=no
|
|
+ if { ac_try='${CC-cc} -c $CFLAGS conftest.c -o conftest.o 1>&5'
|
|
+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
|
|
+ (eval $ac_try) 2>&5
|
|
+ ac_status=$?
|
|
+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
|
+ test $ac_status = 0; }; }; then
|
|
+ libc_cv_x86_have_apx=yes
|
|
+ fi
|
|
+ rm -rf conftest*
|
|
+fi
|
|
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_x86_have_apx" >&5
|
|
+printf "%s\n" "$libc_cv_x86_have_apx" >&6; }
|
|
+if test $libc_cv_x86_have_apx = yes; then
|
|
+ printf "%s\n" "#define HAVE_X86_APX 1" >>confdefs.h
|
|
+
|
|
+fi
|
|
+config_vars="$config_vars
|
|
+have-x86-apx = $libc_cv_x86_have_apx"
|
|
+
|
|
test -n "$critic_missing" && as_fn_error $? "
|
|
*** $critic_missing" "$LINENO" 5
|
|
|
|
diff --git a/sysdeps/x86_64/configure.ac b/sysdeps/x86_64/configure.ac
|
|
index c714c47351e70390..c7b68544a2c79ae5 100644
|
|
--- a/sysdeps/x86_64/configure.ac
|
|
+++ b/sysdeps/x86_64/configure.ac
|
|
@@ -76,5 +76,23 @@ EOF
|
|
rm -rf conftest*])
|
|
LIBC_CONFIG_VAR([have-mamx-tile], [$libc_cv_x86_have_amx_tile])
|
|
|
|
+# Check if -mapxf is enabled.
|
|
+AC_CACHE_CHECK(whether -mapxf is enabled,
|
|
+ libc_cv_x86_have_apx, [dnl
|
|
+cat > conftest.c <<EOF
|
|
+#ifndef __APX_F__
|
|
+# error APX isn't enabled
|
|
+#endif
|
|
+EOF
|
|
+ libc_cv_x86_have_apx=no
|
|
+ if AC_TRY_COMMAND(${CC-cc} -c $CFLAGS conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD); then
|
|
+ libc_cv_x86_have_apx=yes
|
|
+ fi
|
|
+ rm -rf conftest*])
|
|
+if test $libc_cv_x86_have_apx = yes; then
|
|
+ AC_DEFINE(HAVE_X86_APX)
|
|
+fi
|
|
+LIBC_CONFIG_VAR([have-x86-apx], [$libc_cv_x86_have_apx])
|
|
+
|
|
test -n "$critic_missing" && AC_MSG_ERROR([
|
|
*** $critic_missing])
|
|
diff --git a/sysdeps/x86_64/fpu/multiarch/Makefile b/sysdeps/x86_64/fpu/multiarch/Makefile
|
|
index 6ddd50240ce33d22..cbe09d49f49581f1 100644
|
|
--- a/sysdeps/x86_64/fpu/multiarch/Makefile
|
|
+++ b/sysdeps/x86_64/fpu/multiarch/Makefile
|
|
@@ -38,29 +38,36 @@ libm-sysdep_routines += \
|
|
s_truncf-avx \
|
|
# libm-sysdep_routines
|
|
else
|
|
+ifeq (no,$(have-x86-apx))
|
|
libm-sysdep_routines += \
|
|
- e_asin-fma \
|
|
e_asin-fma4 \
|
|
+ e_atan2-fma4 \
|
|
+ e_exp-fma4 \
|
|
+ e_log-fma4 \
|
|
+ e_pow-fma4 \
|
|
+ s_atan-fma4 \
|
|
+ s_sin-fma4 \
|
|
+ s_sincos-fma4 \
|
|
+ s_tan-fma4 \
|
|
+# libm-sysdep_routines
|
|
+endif
|
|
+libm-sysdep_routines += \
|
|
+ e_asin-fma \
|
|
e_atan2-avx \
|
|
e_atan2-fma \
|
|
- e_atan2-fma4 \
|
|
e_exp-avx \
|
|
e_exp-fma \
|
|
- e_exp-fma4 \
|
|
e_exp2f-fma \
|
|
e_expf-fma \
|
|
e_log-avx \
|
|
e_log-fma \
|
|
- e_log-fma4 \
|
|
e_log2-fma \
|
|
e_log2f-fma \
|
|
e_logf-fma \
|
|
e_pow-fma \
|
|
- e_pow-fma4 \
|
|
e_powf-fma \
|
|
s_atan-avx \
|
|
s_atan-fma \
|
|
- s_atan-fma4 \
|
|
s_ceil-sse4_1 \
|
|
s_ceilf-sse4_1 \
|
|
s_cosf-fma \
|
|
@@ -77,17 +84,14 @@ libm-sysdep_routines += \
|
|
s_roundevenf-sse4_1 \
|
|
s_sin-avx \
|
|
s_sin-fma \
|
|
- s_sin-fma4 \
|
|
s_sincos-avx \
|
|
s_sincos-fma \
|
|
- s_sincos-fma4 \
|
|
s_sincosf-fma \
|
|
s_sincosf-sse2 \
|
|
s_sinf-fma \
|
|
s_sinf-sse2 \
|
|
s_tan-avx \
|
|
s_tan-fma \
|
|
- s_tan-fma4 \
|
|
s_trunc-sse4_1 \
|
|
s_truncf-sse4_1 \
|
|
# libm-sysdep_routines
|
|
diff --git a/sysdeps/x86_64/fpu/multiarch/ifunc-avx-fma4.h b/sysdeps/x86_64/fpu/multiarch/ifunc-avx-fma4.h
|
|
index 7719188888fbec38..d126cf9cd5ae55e4 100644
|
|
--- a/sysdeps/x86_64/fpu/multiarch/ifunc-avx-fma4.h
|
|
+++ b/sysdeps/x86_64/fpu/multiarch/ifunc-avx-fma4.h
|
|
@@ -33,8 +33,10 @@ IFUNC_SELECTOR (void)
|
|
&& CPU_FEATURE_USABLE_P (cpu_features, AVX2))
|
|
return OPTIMIZE (fma);
|
|
|
|
+#ifndef HAVE_X86_APX
|
|
if (CPU_FEATURE_USABLE_P (cpu_features, FMA4))
|
|
return OPTIMIZE (fma4);
|
|
+#endif
|
|
|
|
if (CPU_FEATURE_USABLE_P (cpu_features, AVX))
|
|
return OPTIMIZE (avx);
|
|
diff --git a/sysdeps/x86_64/fpu/multiarch/ifunc-fma4.h b/sysdeps/x86_64/fpu/multiarch/ifunc-fma4.h
|
|
index c35ba13845b7914b..18d372d25cb598f2 100644
|
|
--- a/sysdeps/x86_64/fpu/multiarch/ifunc-fma4.h
|
|
+++ b/sysdeps/x86_64/fpu/multiarch/ifunc-fma4.h
|
|
@@ -32,8 +32,10 @@ IFUNC_SELECTOR (void)
|
|
&& CPU_FEATURE_USABLE_P (cpu_features, AVX2))
|
|
return OPTIMIZE (fma);
|
|
|
|
+#ifndef HAVE_X86_APX
|
|
if (CPU_FEATURE_USABLE_P (cpu_features, FMA4))
|
|
return OPTIMIZE (fma4);
|
|
+#endif
|
|
|
|
return OPTIMIZE (sse2);
|
|
}
|