[PATCH] Check if -mamx-tile works for testing

H.J. Lu hjl.tools@gmail.com
Wed Dec 18 10:56:14 GMT 2024


Since -mamx-tile is used only for testing, use LIBC_TRY_TEST_CC_COMMAND,
instead of LIBC_TRY_CC_AND_TEST_CC_COMMAND to check it and don't check
__builtin_ia32_ldtilecfg for Clang.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
 sysdeps/x86_64/configure    | 63 +++++++++++--------------------------
 sysdeps/x86_64/configure.ac | 32 +++++++++----------
 2 files changed, 32 insertions(+), 63 deletions(-)

diff --git a/sysdeps/x86_64/configure b/sysdeps/x86_64/configure
index 5846b67c2f..bbf520bfc9 100755
--- a/sysdeps/x86_64/configure
+++ b/sysdeps/x86_64/configure
@@ -211,46 +211,10 @@ config_vars="$config_vars
 enable-cet = $enable_cet"
 
 # Check if -mamx-tile works properly.
-check_x86_have_amx_tile ()
-{
-  eval $1=no
-  if grep -q __builtin_ia32_ldtilecfg conftest; then
-    eval $1=yes
-  fi
-}
-
-conftest_code="
-#include <x86intrin.h>
-"
 
 cat > conftest.c <<EOF
-$conftest_code
+#include <x86intrin.h>
 EOF
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -mamx-tile works properly" >&5
-printf %s "checking whether -mamx-tile works properly... " >&6; }
-if test ${libc_cv_x86_have_amx_tile+y}
-then :
-  printf %s "(cached) " >&6
-else case e in #(
-  e)   if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -E -mamx-tile conftest.c -o conftest 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
-    check_x86_have_amx_tile libc_cv_x86_have_amx_tile
-  else
-    libc_cv_x86_have_amx_tile=no
-  fi
- ;;
-esac
-fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_x86_have_amx_tile" >&5
-printf "%s\n" "$libc_cv_x86_have_amx_tile" >&6; }
-if test "$TEST_CC" = "$CC"; then
-  libc_cv_test_x86_have_amx_tile=$libc_cv_x86_have_amx_tile
-else
 
 saved_CC="$CC"
 CC="$TEST_CC"
@@ -260,17 +224,27 @@ if test ${libc_cv_test_x86_have_amx_tile+y}
 then :
   printf %s "(cached) " >&6
 else case e in #(
-  e)       if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -E -mamx-tile conftest.c -o conftest 1>&5'
+  e)     if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -E -mamx-tile conftest.c -o conftest 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
-	check_x86_have_amx_tile libc_cv_test_x86_have_amx_tile
-      else
-	libc_cv_test_x86_have_amx_tile=no
-      fi ;;
+    then
+
+if test $libc_cv_test_clang = yes; then
+  libc_cv_test_x86_have_amx_tile=yes
+else
+  if grep -q __builtin_ia32_ldtilecfg conftest; then
+    libc_cv_test_x86_have_amx_tile=yes
+  else
+    libc_cv_test_x86_have_amx_tile=no
+  fi
+fi
+
+    else
+      libc_cv_test_x86_have_amx_tile=no
+    fi ;;
 esac
 fi
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_test_x86_have_amx_tile" >&5
@@ -278,10 +252,9 @@ printf "%s\n" "$libc_cv_test_x86_have_amx_tile" >&6; }
 
 CC="$saved_CC"
 
-fi
 rm -f conftest*
 config_vars="$config_vars
-have-mamx-tile = $libc_cv_x86_have_amx_tile"
+have-mamx-tile = $libc_cv_test_x86_have_amx_tile"
 
 # Check if -mapxf is enabled.
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -mapxf is enabled" >&5
diff --git a/sysdeps/x86_64/configure.ac b/sysdeps/x86_64/configure.ac
index fcf457d03b..4a3f7f4541 100644
--- a/sysdeps/x86_64/configure.ac
+++ b/sysdeps/x86_64/configure.ac
@@ -68,27 +68,23 @@ fi
 LIBC_CONFIG_VAR([enable-cet], [$enable_cet])
 
 # Check if -mamx-tile works properly.
-check_x86_have_amx_tile ()
-{
-  eval $1=no
-  if grep -q __builtin_ia32_ldtilecfg conftest; then
-    eval $1=yes
-  fi
-}
-
-conftest_code="
-#include <x86intrin.h>
-"
-LIBC_TRY_CC_AND_TEST_CC_COMMAND([whether -mamx-tile works properly],
-  [$conftest_code],
+LIBC_TRY_TEST_CC_COMMAND([whether -mamx-tile works properly],
+  [#include <x86intrin.h>],
   [-E -mamx-tile],
-  libc_cv_x86_have_amx_tile,
-  [check_x86_have_amx_tile libc_cv_x86_have_amx_tile],
-  [libc_cv_x86_have_amx_tile=no],
   libc_cv_test_x86_have_amx_tile,
-  [check_x86_have_amx_tile libc_cv_test_x86_have_amx_tile],
+  [
+if test $libc_cv_test_clang = yes; then
+  libc_cv_test_x86_have_amx_tile=yes
+else
+  if grep -q __builtin_ia32_ldtilecfg conftest; then
+    libc_cv_test_x86_have_amx_tile=yes
+  else
+    libc_cv_test_x86_have_amx_tile=no
+  fi
+fi
+  ],
   [libc_cv_test_x86_have_amx_tile=no])
-LIBC_CONFIG_VAR([have-mamx-tile], [$libc_cv_x86_have_amx_tile])
+LIBC_CONFIG_VAR([have-mamx-tile], [$libc_cv_test_x86_have_amx_tile])
 
 # Check if -mapxf is enabled.
 AC_CACHE_CHECK(whether -mapxf is enabled,
-- 
2.47.1



More information about the Libc-alpha mailing list