Skip to content

Commit

Permalink
CONFIGURE: Refactor compiler version checks for SIMD instructions sets
Browse files Browse the repository at this point in the history
  • Loading branch information
lephilousophe committed Sep 2, 2024
1 parent 3ede09f commit e994d28
Showing 1 changed file with 21 additions and 37 deletions.
58 changes: 21 additions & 37 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -7104,6 +7104,13 @@ case $_host_cpu in
_ext_avx2=yes
fi
_ext_neon=no
# SSE2 is always available on x86_64
if (test "$have_clang" = yes && (test $_clang_major -lt 3) || (test $_clang_major -eq 3 && test $_clang_minor -lt 7)) ||
(test "$have_gcc" = yes && (test $_cxx_major -lt 4) || (test $_cxx_major -eq 4 && test $_cxx_minor -lt 9)) ||
(test "$have_gcc" != yes); then
# Need GCC 4.9+ or Clang 3.7+ for target pragma
_ext_avx2=no
fi
;;
i[3-6]86)
if test "$_ext_sse2" = auto ; then
Expand All @@ -7113,20 +7120,34 @@ case $_host_cpu in
_ext_avx2=no
fi
_ext_neon=no
if (test "$have_clang" = yes && (test $_clang_major -lt 3) || (test $_clang_major -eq 3 && test $_clang_minor -lt 7)) ||
(test "$have_gcc" = yes && (test $_cxx_major -lt 4) || (test $_cxx_major -eq 4 && test $_cxx_minor -lt 9)) ||
(test "$have_gcc" != yes); then
# Need GCC 4.9+ or Clang 3.7+ for target pragma
_ext_sse2=no
_ext_avx2=no
fi
;;
aarch64)
if test "$_ext_neon" = auto ; then
_ext_neon=yes
fi
_ext_sse2=no
_ext_avx2=no
# On aarch64 neon is always available and doesn't need a target pragma
;;
arm*)
if test "$_ext_neon" = auto ; then
_ext_neon=no
fi
_ext_sse2=no
_ext_avx2=no
if (test "$have_clang" = yes && (test $_clang_major -lt 19) || (test $_clang_major -eq 19 && test $_clang_minor -lt 1)) ||
(test "$have_gcc" = yes && (test $_cxx_major -lt 4) || (test $_cxx_major -eq 4 && test $_cxx_minor -lt 9)) ||
(test "$have_gcc" != yes); then
# Need GCC 4.9+ or Clang 19.1+ for target pragma
_ext_neon=no
fi
;;
*)
_ext_sse2=no
Expand All @@ -7135,43 +7156,6 @@ case $_host_cpu in
;;
esac

if test "$have_clang" = yes; then
# Clang has variable support to target gating of intrinsics
case $_host_cpu in
i[3-6]86)
# SSE2 and AVX2 has been target gated since LLVM 3.7
if (test $_clang_major -lt 3) || (test $_clang_major -eq 3 && test $_clang_minor -lt 7); then
_ext_sse2=no
_ext_avx2=no
fi
;;
arm*)
# NEON has been target gated since LLVM 19.1
if (test $_clang_major -lt 19) || (test $_clang_major -eq 19 && test $_clang_minor -lt 1); then
# But several platforms enables it globally...
if ! echo "$CXXFLAGS" | grep -q -e -mfpu=neon; then
_ext_neon=no
fi
fi
;;
x86_64 | amd64)
# AVX2 has been target gated since LLVM 3.7
# x86_64 always supports SSE2, no need of gating
if (test $_clang_major -lt 3) || (test $_clang_major -eq 3 && test $_clang_minor -lt 7); then
_ext_avx2=no
fi
;;
# aarch64 always supports NEON, no need of gating
esac
elif test "$have_gcc" = yes; then
# Need 4.9 for pragma target
if (test $_cxx_major -lt 4) || (test $_cxx_major -eq 4 && test $_cxx_minor -lt 9); then
_ext_sse2=no
_ext_avx2=no
_ext_neon=no
fi
fi

define_in_config_if_yes "$_ext_sse2" 'SCUMMVM_SSE2'
echo_n "Enabling x86/amd64 SSE2... "
echo "$_ext_sse2"
Expand Down

0 comments on commit e994d28

Please sign in to comment.