build: Checking for compiler support of LoongArch LSX should be guarded

In the configure script, checking whether the LoongArch LSX intrinsics
are supported by the compiler was done unconditionally, regardless of
the targetted host platform. Compared to how we support the other SIMD
platforms and compilers, this is rather unconventional.

We are placing this check under the guard of its own platform, for the
time being. A full solution, in line with the rest of the configure.ac
patterns concering SIMD optimizations, is TODO.

We also do an overall cleanup in the SIMD section of configure.ac, and,
finally, we regenerate the configure script.
This commit is contained in:
Cosmin Truta 2024-02-20 23:14:32 +02:00
parent 29e31f622f
commit 14a348ddc8
2 changed files with 219 additions and 220 deletions

231
configure vendored
View File

@ -1544,36 +1544,36 @@ Optional Features:
default - use --disable-unversioned-libpng-config to default - use --disable-unversioned-libpng-config to
change this. change this.
--enable-hardware-optimizations --enable-hardware-optimizations
Enable hardware optimizations: =no/off, yes/on: Enable hardware optimizations: =no/off, yes/on.
--enable-arm-neon Enable ARM NEON optimizations: =no/off, check, api, --enable-arm-neon Enable ARM NEON optimizations: =no/off, check, api,
yes/on: no/off: disable the optimizations; check: yes/on. no/off: disable the optimizations; check:
use internal checking code (deprecated and poorly use internal checking code (deprecated and poorly
supported); api: disable by default, enable by a supported); api: disable by default, enable by a
call to png_set_option; yes/on: turn on call to png_set_option; yes/on: turn on
unconditionally. If not specified: determined by the unconditionally. If not specified: determined by the
compiler. compiler.
--enable-mips-msa Enable MIPS MSA optimizations: =no/off, check, api, --enable-mips-msa Enable MIPS MSA optimizations: =no/off, check, api,
yes/on: no/off: disable the optimizations; check: yes/on. no/off: disable the optimizations; check:
use internal checking code (deprecated and poorly use internal checking code (deprecated and poorly
supported); api: disable by default, enable by a supported); api: disable by default, enable by a
call to png_set_option; yes/on: turn on call to png_set_option; yes/on: turn on
unconditionally. If not specified: determined by the unconditionally. If not specified: determined by the
compiler. compiler.
--enable-mips-mmi Enable MIPS MMI optimizations: =no/off, check, api, --enable-mips-mmi Enable MIPS MMI optimizations: =no/off, check, api,
yes/on: no/off: disable the optimizations; check: yes/on. no/off: disable the optimizations; check:
use internal checking code (deprecated and poorly use internal checking code (deprecated and poorly
supported); api: disable by default, enable by a supported); api: disable by default, enable by a
call to png_set_option; yes/on: turn on call to png_set_option; yes/on: turn on
unconditionally. If not specified: determined by the unconditionally. If not specified: determined by the
compiler. compiler.
--enable-intel-sse Enable Intel SSE optimizations: =no/off, yes/on: --enable-intel-sse Enable Intel SSE optimizations: =no/off, yes/on.
no/off: disable the optimizations; yes/on: enable no/off: disable the optimizations; yes/on: enable
the optimizations. If not specified: determined by the optimizations. If not specified: determined by
the compiler. the compiler.
--enable-powerpc-vsx Enable POWERPC VSX optimizations: =no/off, check, --enable-powerpc-vsx Enable POWERPC VSX optimizations: =no/off, check,
api, yes/on: no/off: disable the optimizations; api, yes/on. no/off: disable the optimizations;
check: use internal checking code api: disable by check: use internal checking code; api: disable by
default, enable by a call to png_set_option yes/on: default, enable by a call to png_set_option; yes/on:
turn on unconditionally. If not specified: turn on unconditionally. If not specified:
determined by the compiler. determined by the compiler.
--enable-loongarch-lsx --enable-loongarch-lsx
@ -14227,9 +14227,9 @@ if test "$have_ld_version_script" = "yes"; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for symbol prefix" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for symbol prefix" >&5
printf %s "checking for symbol prefix... " >&6; } printf %s "checking for symbol prefix... " >&6; }
SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \ SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \
| ${CPP-${CC-gcc} -E} - 2>&1 \ | ${CPP:-${CC:-gcc} -E} - 2>&1 \
| ${EGREP-grep} "^PREFIX=" \ | ${EGREP:-grep} "^PREFIX=" \
| ${SED-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"` | ${SED:-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"`
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SYMBOL_PREFIX" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SYMBOL_PREFIX" >&5
printf "%s\n" "$SYMBOL_PREFIX" >&6; } printf "%s\n" "$SYMBOL_PREFIX" >&6; }
@ -14429,10 +14429,8 @@ printf "%s\n" "#define PNG_LOONGARCH_LSX_OPT 1" >>confdefs.h
fi fi
# ARM # ARM NEON
# === # ========
#
# ARM NEON (SIMD) support.
# Check whether --enable-arm-neon was given. # Check whether --enable-arm-neon was given.
if test ${enable_arm_neon+y} if test ${enable_arm_neon+y}
@ -14457,21 +14455,22 @@ printf "%s\n" "#define PNG_ARM_NEON_API_SUPPORTED /**/" >>confdefs.h
printf "%s\n" "#define PNG_ARM_NEON_OPT 2" >>confdefs.h printf "%s\n" "#define PNG_ARM_NEON_OPT 2" >>confdefs.h
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --enable-arm-neon: please specify 'check' or 'api', if { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --enable-arm-neon: please specify 'check' or 'api';
you want the optimizations unconditionally pass -mfpu=neon if you want the optimizations unconditionally,
to the compiler." >&5 pass '-mfpu=neon' to the compiler." >&5
printf "%s\n" "$as_me: WARNING: --enable-arm-neon: please specify 'check' or 'api', if printf "%s\n" "$as_me: WARNING: --enable-arm-neon: please specify 'check' or 'api';
you want the optimizations unconditionally pass -mfpu=neon if you want the optimizations unconditionally,
to the compiler." >&2;};; pass '-mfpu=neon' to the compiler." >&2;};;
*) *)
as_fn_error $? "--enable-arm-neon=${enable_arm_neon}: invalid value" "$LINENO" 5 as_fn_error $? "--enable-arm-neon=${enable_arm_neon}:
invalid argument" "$LINENO" 5
esac esac
fi fi
# Add ARM-specific files to all builds where $host_cpu is arm ('arm*') or # Add ARM-specific files to all builds where $host_cpu is arm ('arm*') or
# where ARM optimizations were explicitly requested (this allows a fallback # where ARM optimizations were explicitly requested. (This allows a fallback
# if a future host CPU does not match 'arm*') # if a future host CPU does not match 'arm*'.)
if test "$enable_arm_neon" != 'no' && if test "$enable_arm_neon" != 'no' &&
case "$host_cpu" in case "$host_cpu" in
@ -14486,10 +14485,8 @@ else
fi fi
# MIPS # MIPS MSA
# ==== # ========
#
# MIPS MSA (SIMD) support.
# Check whether --enable-mips-msa was given. # Check whether --enable-mips-msa was given.
if test ${enable_mips_msa+y} if test ${enable_mips_msa+y}
@ -14514,21 +14511,22 @@ printf "%s\n" "#define PNG_MIPS_MSA_API_SUPPORTED /**/" >>confdefs.h
printf "%s\n" "#define PNG_MIPS_MSA_OPT 2" >>confdefs.h printf "%s\n" "#define PNG_MIPS_MSA_OPT 2" >>confdefs.h
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --enable-mips-msa: please specify 'check' or 'api', if { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --enable-mips-msa: please specify 'check' or 'api';
you want the optimizations unconditionally pass '-mmsa -mfp64' if you want the optimizations unconditionally,
to the compiler." >&5 pass '-mmsa -mfp64' to the compiler." >&5
printf "%s\n" "$as_me: WARNING: --enable-mips-msa: please specify 'check' or 'api', if printf "%s\n" "$as_me: WARNING: --enable-mips-msa: please specify 'check' or 'api';
you want the optimizations unconditionally pass '-mmsa -mfp64' if you want the optimizations unconditionally,
to the compiler." >&2;};; pass '-mmsa -mfp64' to the compiler." >&2;};;
*) *)
as_fn_error $? "--enable-mips-msa=${enable_mips_msa}: invalid value" "$LINENO" 5 as_fn_error $? "--enable-mips-msa=${enable_mips_msa}:
invalid argument" "$LINENO" 5
esac esac
fi fi
# Add MIPS-specific files to all builds where $host_cpu is mips ('mips*') or # Add MIPS-specific files to all builds where $host_cpu is mips ('mips*') or
# where MIPS optimizations were explicitly requested (this allows a fallback # where MIPS optimizations were explicitly requested. (This allows a fallback
# if a future host CPU does not match 'mips*') # if a future host CPU does not match 'mips*'.)
if test "$enable_mips_msa" != 'no' && if test "$enable_mips_msa" != 'no' &&
case "$host_cpu" in case "$host_cpu" in
@ -14542,10 +14540,8 @@ else
fi fi
# MIPS # MIPS MMI
# === # ========
#
# MIPS MMI (SIMD) support.
# Check whether --enable-mips-mmi was given. # Check whether --enable-mips-mmi was given.
if test ${enable_mips_mmi+y} if test ${enable_mips_mmi+y}
@ -14570,25 +14566,26 @@ printf "%s\n" "#define PNG_MIPS_MMI_API_SUPPORTED /**/" >>confdefs.h
printf "%s\n" "#define PNG_MIPS_MMI_OPT 1" >>confdefs.h printf "%s\n" "#define PNG_MIPS_MMI_OPT 1" >>confdefs.h
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --enable-mips-mmi: please specify 'check' or 'api', if { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --enable-mips-mmi: please specify 'check' or 'api';
you want the optimizations unconditionally pass '-mloongson-mmi -march=loongson3a' if you want the optimizations unconditionally
to the compiler." >&5 pass '-mloongson-mmi -march=loongson3a' to the compiler." >&5
printf "%s\n" "$as_me: WARNING: --enable-mips-mmi: please specify 'check' or 'api', if printf "%s\n" "$as_me: WARNING: --enable-mips-mmi: please specify 'check' or 'api';
you want the optimizations unconditionally pass '-mloongson-mmi -march=loongson3a' if you want the optimizations unconditionally
to the compiler." >&2;};; pass '-mloongson-mmi -march=loongson3a' to the compiler." >&2;};;
*) *)
as_fn_error $? "--enable-mips-mmi=${enable_mips_mmi}: invalid value" "$LINENO" 5 as_fn_error $? "--enable-mips-mmi=${enable_mips_mmi}:
invalid argument" "$LINENO" 5
esac esac
fi fi
# Add MIPS specific files to all builds where the host_cpu is mips ('mips*') or # Add MIPS specific files to all builds where the host_cpu is mips ('mips*') or
# where MIPS optimizations were explicitly requested (this allows a fallback if a # where MIPS optimizations were explicitly requested. (This allows a fallback
# future host CPU does not match 'mips*') # if a future host CPU does not match 'mips*'.)
if test "$enable_mips_mmi" != 'no' && if test "$enable_mips_mmi" != 'no' &&
case "$host_cpu" in case "$host_cpu" in
mipsel*|mips64el*) :;; mipsel*|mips64el*) : ;;
esac; then esac; then
PNG_MIPS_MMI_TRUE= PNG_MIPS_MMI_TRUE=
PNG_MIPS_MMI_FALSE='#' PNG_MIPS_MMI_FALSE='#'
@ -14598,10 +14595,8 @@ else
fi fi
# INTEL # INTEL SSE
# ===== # =========
#
# INTEL SSE (SIMD) support.
# Check whether --enable-intel-sse was given. # Check whether --enable-intel-sse was given.
if test ${enable_intel_sse+y} if test ${enable_intel_sse+y}
@ -14619,14 +14614,15 @@ printf "%s\n" "#define PNG_INTEL_SSE_OPT 0" >>confdefs.h
printf "%s\n" "#define PNG_INTEL_SSE_OPT 1" >>confdefs.h printf "%s\n" "#define PNG_INTEL_SSE_OPT 1" >>confdefs.h
;; ;;
*) *)
as_fn_error $? "--enable-intel-sse=${enable_intel_sse}: invalid value" "$LINENO" 5 as_fn_error $? "--enable-intel-sse=${enable_intel_sse}:
invalid argument" "$LINENO" 5
esac esac
fi fi
# Add Intel-specific files to all builds where $host_cpu is Intel ('x86*') or # Add Intel-specific files to all builds where $host_cpu is Intel ('x86*') or
# where Intel optimizations were explicitly requested (this allows a fallback # where Intel optimizations were explicitly requested. (This allows a fallback
# if a future host CPU does not match 'x86*') # if a future host CPU does not match 'x86*'.)
if test "$enable_intel_sse" != 'no' && if test "$enable_intel_sse" != 'no' &&
case "$host_cpu" in case "$host_cpu" in
i?86|x86_64) : ;; i?86|x86_64) : ;;
@ -14640,10 +14636,8 @@ else
fi fi
# PowerPC # POWERPC VSX
# ======= # ===========
#
# PowerPC VSX (SIMD) support.
# Check whether --enable-powerpc-vsx was given. # Check whether --enable-powerpc-vsx was given.
if test ${enable_powerpc_vsx+y} if test ${enable_powerpc_vsx+y}
@ -14660,10 +14654,10 @@ printf "%s\n" "#define PNG_POWERPC_VSX_OPT 0" >>confdefs.h
printf "%s\n" "#define PNG_POWERPC_VSX_CHECK_SUPPORTED /**/" >>confdefs.h printf "%s\n" "#define PNG_POWERPC_VSX_CHECK_SUPPORTED /**/" >>confdefs.h
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --enable-powerpc-vsx Please check contrib/powerpc/README file { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --enable-powerpc-vsx: please see contrib/powerpc/README
for the list of supported OSes." >&5 for the list of supported systems." >&5
printf "%s\n" "$as_me: WARNING: --enable-powerpc-vsx Please check contrib/powerpc/README file printf "%s\n" "$as_me: WARNING: --enable-powerpc-vsx: please see contrib/powerpc/README
for the list of supported OSes." >&2;};; for the list of supported systems." >&2;};;
api) api)
printf "%s\n" "#define PNG_POWERPC_VSX_API_SUPPORTED /**/" >>confdefs.h printf "%s\n" "#define PNG_POWERPC_VSX_API_SUPPORTED /**/" >>confdefs.h
@ -14672,21 +14666,22 @@ printf "%s\n" "#define PNG_POWERPC_VSX_API_SUPPORTED /**/" >>confdefs.h
printf "%s\n" "#define PNG_POWERPC_VSX_OPT 2" >>confdefs.h printf "%s\n" "#define PNG_POWERPC_VSX_OPT 2" >>confdefs.h
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --enable-powerpc-vsx: please specify 'check' or 'api', if { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --enable-powerpc-vsx: please specify 'check' or 'api';
you want the optimizations unconditionally pass '-maltivec -mvsx' if you want the optimizations unconditionally,
or '-mcpu=power8' to the compiler." >&5 pass '-maltivec -mvsx' or '-mcpu=power8' to the compiler." >&5
printf "%s\n" "$as_me: WARNING: --enable-powerpc-vsx: please specify 'check' or 'api', if printf "%s\n" "$as_me: WARNING: --enable-powerpc-vsx: please specify 'check' or 'api';
you want the optimizations unconditionally pass '-maltivec -mvsx' if you want the optimizations unconditionally,
or '-mcpu=power8' to the compiler." >&2;};; pass '-maltivec -mvsx' or '-mcpu=power8' to the compiler." >&2;};;
*) *)
as_fn_error $? "--enable-powerpc-vsx=${enable_powerpc_vsx}: invalid value" "$LINENO" 5 as_fn_error $? "--enable-powerpc-vsx=${enable_powerpc_vsx}:
invalid argument" "$LINENO" 5
esac esac
fi fi
# Add PowerPC-specific files to all builds where $host_cpu is powerpc('powerpc*') # Add PowerPC-specific files to all builds where $host_cpu is powerpc
# or where PowerPC optimizations were explicitly requested (this allows a fallback # ('powerpc*') or where PowerPC optimizations were explicitly requested.
# if a future host CPU does not match 'powerpc*') # (This allows a fallback if a future host CPU does not match 'powerpc*'.)
if test "$enable_powerpc_vsx" != 'no' && if test "$enable_powerpc_vsx" != 'no' &&
case "$host_cpu" in case "$host_cpu" in
@ -14700,38 +14695,8 @@ else
fi fi
# LOONGARCH # LOONGARCH LSX
# === # =============
#
# LOONGARCH LSX (SIMD) support
if test "$LSX_CFLAGS" = ''; then
LSX_CFLAGS="-mlsx"
fi
compiler_support_loongarch_lsx=no
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to use loongarch LSX intrinsics" >&5
printf %s "checking whether to use loongarch LSX intrinsics... " >&6; }
save_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS $LSX_CFLAGS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include<lsxintrin.h>
int main(){
__m128i a, b, c;
a = __lsx_vadd_w(b, c);
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
compiler_support_loongarch_lsx=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
CFLAGS=$save_CFLAGS
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $compiler_support_loongarch_lsx" >&5
printf "%s\n" "$compiler_support_loongarch_lsx" >&6; }
# Check whether --enable-loongarch-lsx was given. # Check whether --enable-loongarch-lsx was given.
if test ${enable_loongarch_lsx+y} if test ${enable_loongarch_lsx+y}
@ -14750,13 +14715,44 @@ printf "%s\n" "#define PNG_LOONGARCH_LSX_OPT 1" >>confdefs.h
;; ;;
*) *)
as_fn_error $? "--enable-loongarch-lsx=${enable_loongarch_lsx}: invalid value" "$LINENO" 5 as_fn_error $? "--enable-loongarch-lsx=${enable_loongarch_lsx}:
invalid argument" "$LINENO" 5
esac esac
fi fi
if test "$enable_loongarch_lsx" != 'no'; then # FIXME: This section should not be needed.
if test $compiler_support_loongarch_lsx = yes; then if test "$enable_loongarch_lsx" != "no" &&
case "$host_cpu" in
loongarch*) : ;;
*) test "$enable_loongarch_lsx" != '' ;;
esac
then
compiler_support_loongarch_lsx=no
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to use LoongArch LSX intrinsics" >&5
printf %s "checking whether to use LoongArch LSX intrinsics... " >&6; }
save_CFLAGS="$CFLAGS"
LSX_CFLAGS="${LSX_CFLAGS:-"-mlsx"}"
CFLAGS="$CFLAGS $LSX_CFLAGS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <lsxintrin.h>
int main(){
__m128i a, b, c;
a = __lsx_vadd_w(b, c);
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
compiler_support_loongarch_lsx=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
CFLAGS="$save_CFLAGS"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $compiler_support_loongarch_lsx" >&5
printf "%s\n" "$compiler_support_loongarch_lsx" >&6; }
if test "$compiler_support_loongarch_lsx" = "yes"; then
printf "%s\n" "#define PNG_LOONGARCH_LSX_OPT 1" >>confdefs.h printf "%s\n" "#define PNG_LOONGARCH_LSX_OPT 1" >>confdefs.h
@ -14766,14 +14762,15 @@ printf "%s\n" "$as_me: WARNING: Compiler does not support loongarch LSX." >&2;}
fi fi
fi fi
# Add LOONGARCH specific files to all builds where the host_cpu is loongarch ('loongarch*') or # Add LoongArch specific files to all builds where the host_cpu is loongarch
# where LOONGARCH optimizations were explicitly requested (this allows a fallback if a # ('loongarch*') or where LoongArch optimizations were explicitly requested.
# future host CPU does not match 'loongarch*') # (This allows a fallback if a future host CPU does not match 'loongarch*'.)
if test "$enable_loongarch_lsx" != 'no' && test $compiler_support_loongarch_lsx = yes && if test "$enable_loongarch_lsx" != "no" &&
test "$compiler_support_loongarch_lsx" = "yes" &&
case "$host_cpu" in case "$host_cpu" in
loongarch*) :;; loongarch*) : ;;
*) test "$enable_loongarch_lsx" != '';; *) test "$enable_loongarch_lsx" != '' ;;
esac; then esac; then
PNG_LOONGARCH_LSX_TRUE= PNG_LOONGARCH_LSX_TRUE=
PNG_LOONGARCH_LSX_FALSE='#' PNG_LOONGARCH_LSX_FALSE='#'

View File

@ -226,9 +226,9 @@ AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
if test "$have_ld_version_script" = "yes"; then if test "$have_ld_version_script" = "yes"; then
AC_MSG_CHECKING([for symbol prefix]) AC_MSG_CHECKING([for symbol prefix])
SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \ SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \
| ${CPP-${CC-gcc} -E} - 2>&1 \ | ${CPP:-${CC:-gcc} -E} - 2>&1 \
| ${EGREP-grep} "^PREFIX=" \ | ${EGREP:-grep} "^PREFIX=" \
| ${SED-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"` | ${SED:-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"`
AC_SUBST(SYMBOL_PREFIX) AC_SUBST(SYMBOL_PREFIX)
AC_MSG_RESULT($SYMBOL_PREFIX) AC_MSG_RESULT($SYMBOL_PREFIX)
fi fi
@ -321,7 +321,7 @@ AM_CONDITIONAL([DO_INSTALL_LIBPNG_CONFIG],
# #
AC_ARG_ENABLE([hardware-optimizations], AC_ARG_ENABLE([hardware-optimizations],
AS_HELP_STRING([[[--enable-hardware-optimizations]]], AS_HELP_STRING([[[--enable-hardware-optimizations]]],
[Enable hardware optimizations: =no/off, yes/on:]), [Enable hardware optimizations: =no/off, yes/on.]),
[case "$enableval" in [case "$enableval" in
no|off) no|off)
# disable hardware optimization on all systems: # disable hardware optimization on all systems:
@ -379,17 +379,16 @@ AC_ARG_ENABLE([hardware-optimizations],
;; ;;
esac]) esac])
# ARM # ARM NEON
# === # ========
#
# ARM NEON (SIMD) support.
AC_ARG_ENABLE([arm-neon], AC_ARG_ENABLE([arm-neon],
AS_HELP_STRING([[[--enable-arm-neon]]], AS_HELP_STRING([[[--enable-arm-neon]]],
[Enable ARM NEON optimizations: =no/off, check, api, yes/on:] [Enable ARM NEON optimizations: =no/off, check, api, yes/on.]
[no/off: disable the optimizations; check: use internal checking code] [no/off: disable the optimizations;]
[(deprecated and poorly supported); api: disable by default, enable by] [check: use internal checking code (deprecated and poorly supported);]
[a call to png_set_option; yes/on: turn on unconditionally.] [api: disable by default, enable by a call to png_set_option;]
[yes/on: turn on unconditionally.]
[If not specified: determined by the compiler.]), [If not specified: determined by the compiler.]),
[case "$enableval" in [case "$enableval" in
no|off) no|off)
@ -407,16 +406,17 @@ AC_ARG_ENABLE([arm-neon],
yes|on) yes|on)
AC_DEFINE([PNG_ARM_NEON_OPT], [2], AC_DEFINE([PNG_ARM_NEON_OPT], [2],
[Enable ARM Neon optimizations]) [Enable ARM Neon optimizations])
AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api', if] AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api';]
[you want the optimizations unconditionally pass -mfpu=neon] [if you want the optimizations unconditionally,]
[to the compiler.]);; [pass '-mfpu=neon' to the compiler.]);;
*) *)
AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}: invalid value]) AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}:]
[invalid argument])
esac]) esac])
# Add ARM-specific files to all builds where $host_cpu is arm ('arm*') or # Add ARM-specific files to all builds where $host_cpu is arm ('arm*') or
# where ARM optimizations were explicitly requested (this allows a fallback # where ARM optimizations were explicitly requested. (This allows a fallback
# if a future host CPU does not match 'arm*') # if a future host CPU does not match 'arm*'.)
AM_CONDITIONAL([PNG_ARM_NEON], AM_CONDITIONAL([PNG_ARM_NEON],
[test "$enable_arm_neon" != 'no' && [test "$enable_arm_neon" != 'no' &&
@ -425,17 +425,16 @@ AM_CONDITIONAL([PNG_ARM_NEON],
*) test "$enable_arm_neon" != '' ;; *) test "$enable_arm_neon" != '' ;;
esac]) esac])
# MIPS # MIPS MSA
# ==== # ========
#
# MIPS MSA (SIMD) support.
AC_ARG_ENABLE([mips-msa], AC_ARG_ENABLE([mips-msa],
AS_HELP_STRING([[[--enable-mips-msa]]], AS_HELP_STRING([[[--enable-mips-msa]]],
[Enable MIPS MSA optimizations: =no/off, check, api, yes/on:] [Enable MIPS MSA optimizations: =no/off, check, api, yes/on.]
[no/off: disable the optimizations; check: use internal checking code] [no/off: disable the optimizations;]
[(deprecated and poorly supported); api: disable by default, enable by] [check: use internal checking code (deprecated and poorly supported);]
[a call to png_set_option; yes/on: turn on unconditionally.] [api: disable by default, enable by a call to png_set_option;]
[yes/on: turn on unconditionally.]
[If not specified: determined by the compiler.]), [If not specified: determined by the compiler.]),
[case "$enableval" in [case "$enableval" in
no|off) no|off)
@ -453,16 +452,17 @@ AC_ARG_ENABLE([mips-msa],
yes|on) yes|on)
AC_DEFINE([PNG_MIPS_MSA_OPT], [2], AC_DEFINE([PNG_MIPS_MSA_OPT], [2],
[Enable MIPS MSA optimizations]) [Enable MIPS MSA optimizations])
AC_MSG_WARN([--enable-mips-msa: please specify 'check' or 'api', if] AC_MSG_WARN([--enable-mips-msa: please specify 'check' or 'api';]
[you want the optimizations unconditionally pass '-mmsa -mfp64'] [if you want the optimizations unconditionally,]
[to the compiler.]);; [pass '-mmsa -mfp64' to the compiler.]);;
*) *)
AC_MSG_ERROR([--enable-mips-msa=${enable_mips_msa}: invalid value]) AC_MSG_ERROR([--enable-mips-msa=${enable_mips_msa}:]
[invalid argument])
esac]) esac])
# Add MIPS-specific files to all builds where $host_cpu is mips ('mips*') or # Add MIPS-specific files to all builds where $host_cpu is mips ('mips*') or
# where MIPS optimizations were explicitly requested (this allows a fallback # where MIPS optimizations were explicitly requested. (This allows a fallback
# if a future host CPU does not match 'mips*') # if a future host CPU does not match 'mips*'.)
AM_CONDITIONAL([PNG_MIPS_MSA], AM_CONDITIONAL([PNG_MIPS_MSA],
[test "$enable_mips_msa" != 'no' && [test "$enable_mips_msa" != 'no' &&
@ -470,17 +470,16 @@ AM_CONDITIONAL([PNG_MIPS_MSA],
mipsel*|mips64el*) : ;; mipsel*|mips64el*) : ;;
esac]) esac])
# MIPS # MIPS MMI
# === # ========
#
# MIPS MMI (SIMD) support.
AC_ARG_ENABLE([mips-mmi], AC_ARG_ENABLE([mips-mmi],
AS_HELP_STRING([[[--enable-mips-mmi]]], AS_HELP_STRING([[[--enable-mips-mmi]]],
[Enable MIPS MMI optimizations: =no/off, check, api, yes/on:] [Enable MIPS MMI optimizations: =no/off, check, api, yes/on.]
[no/off: disable the optimizations; check: use internal checking code] [no/off: disable the optimizations;]
[(deprecated and poorly supported); api: disable by default, enable by] [check: use internal checking code (deprecated and poorly supported);]
[a call to png_set_option; yes/on: turn on unconditionally.] [api: disable by default, enable by a call to png_set_option;]
[yes/on: turn on unconditionally.]
[If not specified: determined by the compiler.]), [If not specified: determined by the compiler.]),
[case "$enableval" in [case "$enableval" in
no|off) no|off)
@ -498,31 +497,30 @@ AC_ARG_ENABLE([mips-mmi],
yes|on) yes|on)
AC_DEFINE([PNG_MIPS_MMI_OPT], [1], AC_DEFINE([PNG_MIPS_MMI_OPT], [1],
[Enable MIPS MMI optimizations]) [Enable MIPS MMI optimizations])
AC_MSG_WARN([--enable-mips-mmi: please specify 'check' or 'api', if] AC_MSG_WARN([--enable-mips-mmi: please specify 'check' or 'api';]
[you want the optimizations unconditionally pass '-mloongson-mmi -march=loongson3a'] [if you want the optimizations unconditionally]
[to the compiler.]);; [pass '-mloongson-mmi -march=loongson3a' to the compiler.]);;
*) *)
AC_MSG_ERROR([--enable-mips-mmi=${enable_mips_mmi}: invalid value]) AC_MSG_ERROR([--enable-mips-mmi=${enable_mips_mmi}:]
[invalid argument])
esac]) esac])
# Add MIPS specific files to all builds where the host_cpu is mips ('mips*') or # Add MIPS specific files to all builds where the host_cpu is mips ('mips*') or
# where MIPS optimizations were explicitly requested (this allows a fallback if a # where MIPS optimizations were explicitly requested. (This allows a fallback
# future host CPU does not match 'mips*') # if a future host CPU does not match 'mips*'.)
AM_CONDITIONAL([PNG_MIPS_MMI], AM_CONDITIONAL([PNG_MIPS_MMI],
[test "$enable_mips_mmi" != 'no' && [test "$enable_mips_mmi" != 'no' &&
case "$host_cpu" in case "$host_cpu" in
mipsel*|mips64el*) :;; mipsel*|mips64el*) : ;;
esac]) esac])
# INTEL # INTEL SSE
# ===== # =========
#
# INTEL SSE (SIMD) support.
AC_ARG_ENABLE([intel-sse], AC_ARG_ENABLE([intel-sse],
AS_HELP_STRING([[[--enable-intel-sse]]], AS_HELP_STRING([[[--enable-intel-sse]]],
[Enable Intel SSE optimizations: =no/off, yes/on:] [Enable Intel SSE optimizations: =no/off, yes/on.]
[no/off: disable the optimizations;] [no/off: disable the optimizations;]
[yes/on: enable the optimizations.] [yes/on: enable the optimizations.]
[If not specified: determined by the compiler.]), [If not specified: determined by the compiler.]),
@ -537,12 +535,13 @@ AC_ARG_ENABLE([intel-sse],
AC_DEFINE([PNG_INTEL_SSE_OPT], [1], AC_DEFINE([PNG_INTEL_SSE_OPT], [1],
[Enable Intel SSE optimizations]);; [Enable Intel SSE optimizations]);;
*) *)
AC_MSG_ERROR([--enable-intel-sse=${enable_intel_sse}: invalid value]) AC_MSG_ERROR([--enable-intel-sse=${enable_intel_sse}:]
[invalid argument])
esac]) esac])
# Add Intel-specific files to all builds where $host_cpu is Intel ('x86*') or # Add Intel-specific files to all builds where $host_cpu is Intel ('x86*') or
# where Intel optimizations were explicitly requested (this allows a fallback # where Intel optimizations were explicitly requested. (This allows a fallback
# if a future host CPU does not match 'x86*') # if a future host CPU does not match 'x86*'.)
AM_CONDITIONAL([PNG_INTEL_SSE], AM_CONDITIONAL([PNG_INTEL_SSE],
[test "$enable_intel_sse" != 'no' && [test "$enable_intel_sse" != 'no' &&
case "$host_cpu" in case "$host_cpu" in
@ -550,16 +549,15 @@ AM_CONDITIONAL([PNG_INTEL_SSE],
*) test "$enable_intel_sse" != '' ;; *) test "$enable_intel_sse" != '' ;;
esac]) esac])
# PowerPC # POWERPC VSX
# ======= # ===========
#
# PowerPC VSX (SIMD) support.
AC_ARG_ENABLE([powerpc-vsx], AC_ARG_ENABLE([powerpc-vsx],
AS_HELP_STRING([[[--enable-powerpc-vsx]]], AS_HELP_STRING([[[--enable-powerpc-vsx]]],
[Enable POWERPC VSX optimizations: =no/off, check, api, yes/on:] [Enable POWERPC VSX optimizations: =no/off, check, api, yes/on.]
[no/off: disable the optimizations; check: use internal checking code] [no/off: disable the optimizations;]
[api: disable by default, enable by a call to png_set_option] [check: use internal checking code;]
[api: disable by default, enable by a call to png_set_option;]
[yes/on: turn on unconditionally.] [yes/on: turn on unconditionally.]
[If not specified: determined by the compiler.]), [If not specified: determined by the compiler.]),
[case "$enableval" in [case "$enableval" in
@ -572,24 +570,25 @@ AS_HELP_STRING([[[--enable-powerpc-vsx]]],
check) check)
AC_DEFINE([PNG_POWERPC_VSX_CHECK_SUPPORTED], [], AC_DEFINE([PNG_POWERPC_VSX_CHECK_SUPPORTED], [],
[Check for POWERPC VSX support at run-time]) [Check for POWERPC VSX support at run-time])
AC_MSG_WARN([--enable-powerpc-vsx Please check contrib/powerpc/README file] AC_MSG_WARN([--enable-powerpc-vsx: please see contrib/powerpc/README]
[for the list of supported OSes.]);; [for the list of supported systems.]);;
api) api)
AC_DEFINE([PNG_POWERPC_VSX_API_SUPPORTED], [], AC_DEFINE([PNG_POWERPC_VSX_API_SUPPORTED], [],
[Turn on POWERPC VSX optimizations at run-time]);; [Turn on POWERPC VSX optimizations at run-time]);;
yes|on) yes|on)
AC_DEFINE([PNG_POWERPC_VSX_OPT], [2], AC_DEFINE([PNG_POWERPC_VSX_OPT], [2],
[Enable POWERPC VSX optimizations]) [Enable POWERPC VSX optimizations])
AC_MSG_WARN([--enable-powerpc-vsx: please specify 'check' or 'api', if] AC_MSG_WARN([--enable-powerpc-vsx: please specify 'check' or 'api';]
[you want the optimizations unconditionally pass '-maltivec -mvsx'] [if you want the optimizations unconditionally,]
[or '-mcpu=power8' to the compiler.]);; [pass '-maltivec -mvsx' or '-mcpu=power8' to the compiler.]);;
*) *)
AC_MSG_ERROR([--enable-powerpc-vsx=${enable_powerpc_vsx}: invalid value]) AC_MSG_ERROR([--enable-powerpc-vsx=${enable_powerpc_vsx}:]
[invalid argument])
esac]) esac])
# Add PowerPC-specific files to all builds where $host_cpu is powerpc('powerpc*') # Add PowerPC-specific files to all builds where $host_cpu is powerpc
# or where PowerPC optimizations were explicitly requested (this allows a fallback # ('powerpc*') or where PowerPC optimizations were explicitly requested.
# if a future host CPU does not match 'powerpc*') # (This allows a fallback if a future host CPU does not match 'powerpc*'.)
AM_CONDITIONAL([PNG_POWERPC_VSX], AM_CONDITIONAL([PNG_POWERPC_VSX],
[test "$enable_powerpc_vsx" != 'no' && [test "$enable_powerpc_vsx" != 'no' &&
@ -597,28 +596,8 @@ AM_CONDITIONAL([PNG_POWERPC_VSX],
powerpc*|ppc64*) : ;; powerpc*|ppc64*) : ;;
esac]) esac])
# LOONGARCH # LOONGARCH LSX
# === # =============
#
# LOONGARCH LSX (SIMD) support
if test "$LSX_CFLAGS" = ''; then
LSX_CFLAGS="-mlsx"
fi
compiler_support_loongarch_lsx=no
AC_MSG_CHECKING(whether to use loongarch LSX intrinsics)
save_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS $LSX_CFLAGS"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include<lsxintrin.h>
int main(){
__m128i a, b, c;
a = __lsx_vadd_w(b, c);
return 0;
}]])],compiler_support_loongarch_lsx=yes)
CFLAGS=$save_CFLAGS
AC_MSG_RESULT($compiler_support_loongarch_lsx)
AC_ARG_ENABLE([loongarch-lsx], AC_ARG_ENABLE([loongarch-lsx],
AS_HELP_STRING([[[--enable-loongarch-lsx]]], AS_HELP_STRING([[[--enable-loongarch-lsx]]],
@ -638,26 +617,49 @@ AC_ARG_ENABLE([loongarch-lsx],
[Enable LOONGARCH LSX optimizations]) [Enable LOONGARCH LSX optimizations])
;; ;;
*) *)
AC_MSG_ERROR([--enable-loongarch-lsx=${enable_loongarch_lsx}: invalid value]) AC_MSG_ERROR([--enable-loongarch-lsx=${enable_loongarch_lsx}:]
[invalid argument])
esac]) esac])
if test "$enable_loongarch_lsx" != 'no'; then # FIXME: This section should not be needed.
if test $compiler_support_loongarch_lsx = yes; then if test "$enable_loongarch_lsx" != "no" &&
AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1], [Enable LOONGARCH LSX optimizations]) case "$host_cpu" in
loongarch*) : ;;
*) test "$enable_loongarch_lsx" != '' ;;
esac
then
compiler_support_loongarch_lsx=no
AC_MSG_CHECKING(whether to use LoongArch LSX intrinsics)
save_CFLAGS="$CFLAGS"
LSX_CFLAGS="${LSX_CFLAGS:-"-mlsx"}"
CFLAGS="$CFLAGS $LSX_CFLAGS"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <lsxintrin.h>
int main(){
__m128i a, b, c;
a = __lsx_vadd_w(b, c);
return 0;
}]])],compiler_support_loongarch_lsx=yes)
CFLAGS="$save_CFLAGS"
AC_MSG_RESULT($compiler_support_loongarch_lsx)
if test "$compiler_support_loongarch_lsx" = "yes"; then
AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1],
[Enable LOONGARCH LSX optimizations])
else else
AC_MSG_WARN([Compiler does not support loongarch LSX.]) AC_MSG_WARN([Compiler does not support loongarch LSX.])
fi fi
fi fi
# Add LOONGARCH specific files to all builds where the host_cpu is loongarch ('loongarch*') or # Add LoongArch specific files to all builds where the host_cpu is loongarch
# where LOONGARCH optimizations were explicitly requested (this allows a fallback if a # ('loongarch*') or where LoongArch optimizations were explicitly requested.
# future host CPU does not match 'loongarch*') # (This allows a fallback if a future host CPU does not match 'loongarch*'.)
AM_CONDITIONAL([PNG_LOONGARCH_LSX], AM_CONDITIONAL([PNG_LOONGARCH_LSX],
[test "$enable_loongarch_lsx" != 'no' && test $compiler_support_loongarch_lsx = yes && [test "$enable_loongarch_lsx" != "no" &&
test "$compiler_support_loongarch_lsx" = "yes" &&
case "$host_cpu" in case "$host_cpu" in
loongarch*) :;; loongarch*) : ;;
*) test "$enable_loongarch_lsx" != '';; *) test "$enable_loongarch_lsx" != '' ;;
esac]) esac])
AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]]) AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])