From 82f43f71b18d0bcac4f0ce83237491cab562bb95 Mon Sep 17 00:00:00 2001 From: John Bowler Date: Tue, 8 Oct 2024 22:07:35 -0700 Subject: [PATCH] configure: Remove architecture-specific checks for hardware optimization This mirrors the CMakeLists.txt improvements in configure.ac and Makefile.am. The complex compiler check is removed from Loongarch so that it is done the same way as everything else along with the curious use of a library in Makefile.am (never done in CMakeLists.txt) The hard-disable of the Intel SSE optimizations done in libpng1.6 to ensure that the configure options did not change mid-version is now removed so the SSE optimizations are on by default (change already made in 1.6 CMakeLists.txt but not configure.) Signed-off-by: John Bowler --- CMakeLists.txt | 9 +- Makefile.am | 50 ++------ configure.ac | 340 ++----------------------------------------------- pngpriv.h | 2 - 4 files changed, 17 insertions(+), 384 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 31e2d9c9a9..355a78dad4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,23 +156,16 @@ set(libpng_mips_sources set(libpng_loongarch_sources loongarch/loongarch_lsx_init.c loongarch/filter_lsx_intrinsics.c) -include(CheckCCompilerFlag) -check_c_compiler_flag("-mlsx" COMPILER_SUPPORTS_LSX) -if(COMPILER_SUPPORTS_LSX) - set_source_files_properties(${libpng_loongarch_sources} - PROPERTIES - COMPILE_FLAGS "-mlsx") -endif() else(PNG_HARDWARE_OPTIMIZATIONS) # Disable opt for all arches add_definitions( - -DPNG_ARM_NEON_OPT=0 -DPNG_ARM_NEON_OPT=0 -DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0 -DPNG_MIPS_MSA_OPT=0 + -DPNG_MIPS_MMI_OPT=0 -DPNG_LOONGARCH_LSX_OPT=0 ) diff --git a/Makefile.am b/Makefile.am index e2e28e4e97..864670ad1d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -104,44 +104,14 @@ lib_LTLIBRARIES=libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c\ pngget.c pngmem.c pngpread.c pngread.c pngrio.c pngrtran.c pngrutil.c\ pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c pngwutil.c\ - png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngusr.dfa - -if PNG_ARM_NEON -libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/arm_init.c\ - arm/filter_neon_intrinsics.c \ - arm/palette_neon_intrinsics.c -endif - -if PNG_MIPS_MSA -libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += mips/mips_init.c\ - mips/filter_msa_intrinsics.c -endif - -if PNG_MIPS_MMI -if !PNG_MIPS_MSA -libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += mips/mips_init.c -endif -libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += mips/filter_mmi_inline_assembly.c -endif - -if PNG_INTEL_SSE -libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += intel/intel_init.c\ - intel/filter_sse2_intrinsics.c -endif - -if PNG_POWERPC_VSX -libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += powerpc/powerpc_init.c\ - powerpc/filter_vsx_intrinsics.c -endif - -if PNG_LOONGARCH_LSX -noinst_LTLIBRARIES= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la -libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_SOURCES = loongarch/loongarch_lsx_init.c\ - loongarch/filter_lsx_intrinsics.c -libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_CFLAGS = -mlsx -libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LIBADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la -# libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la -endif + png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngusr.dfa\ + arm/arm_init.c arm/filter_neon_intrinsics.c\ + arm/palette_neon_intrinsics.c\ + intel/intel_init.c intel/filter_sse2_intrinsics.c\ + loongarch/loongarch_lsx_init.c loongarch/filter_lsx_intrinsics.c\ + mips/mips_init.c mips/filter_msa_intrinsics.c\ + mips/filter_mmi_inline_assembly.c\ + powerpc/powerpc_init.c powerpc/filter_vsx_intrinsics.c nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h @@ -163,10 +133,6 @@ else libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.sym endif -if PNG_LOONGARCH_LSX - libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES += libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la -endif - #distribute headers in /usr/include/libpng/* pkgincludedir= $(includedir)/$(PNGLIB_BASENAME) pkginclude_HEADERS= png.h pngconf.h diff --git a/configure.ac b/configure.ac index 5cce832b8f..da43b9bc43 100644 --- a/configure.ac +++ b/configure.ac @@ -317,346 +317,22 @@ AM_CONDITIONAL([DO_INSTALL_LIBPNG_CONFIG], # AC_ARG_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 no|off) - # disable hardware optimization on all systems: - enable_arm_neon=no - AC_DEFINE([PNG_ARM_NEON_OPT], [0], - [Disable ARM_NEON optimizations]) - enable_mips_msa=no - AC_DEFINE([PNG_MIPS_MSA_OPT], [0], - [Disable MIPS_MSA optimizations]) - enable_mips_mmi=no - AC_DEFINE([PNG_MIPS_MMI_OPT], [0], - [Disable MIPS_MMI optimizations]) - enable_powerpc_vsx=no - AC_DEFINE([PNG_POWERPC_VSX_OPT], [0], - [Disable POWERPC VSX optimizations]) - enable_intel_sse=no - AC_DEFINE([PNG_INTEL_SSE_OPT], [0], - [Disable INTEL_SSE optimizations]) - enable_loongarch_lsx=no + # disable hardware optimization on all systems + AC_DEFINE([PNG_ARM_NEON_OPT], [0], [Disable ARM NEON specific code]) + AC_DEFINE([PNG_INTEL_SSE_OPT], [0], [Disable INTEL SSE specific code]) AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [0], - [Disable LOONGARCH_LSX optimizations]) + [Disable LOONGARCH specific code]) + AC_DEFINE([PNG_MIPS_MMI_OPT], [0], [Disable MIPS MSA specific code]) + AC_DEFINE([PNG_MIPS_MSA_OPT], [0], [Disable MIPS MSI specific code]) + AC_DEFINE([PNG_POWERPC_OPT], [0], [Disable POWERPC VSX specific code]) ;; *) - # allow enabling hardware optimization on any system: - case "$host_cpu" in - arm*|aarch64*) - enable_arm_neon=yes - AC_DEFINE([PNG_ARM_NEON_OPT], [2], - [Enable ARM_NEON optimizations]) - ;; - mipsel*|mips64el*) - enable_mips_mmi=yes - enable_mips_msa=yes - AC_DEFINE([PNG_MIPS_MMI_OPT], [1], - [Enable MIPS_MMI optimizations]) - AC_DEFINE([PNG_MIPS_MSA_OPT], [2], - [Enable MIPS_MSA optimizations]) - ;; - i?86|x86_64) - enable_intel_sse=yes - AC_DEFINE([PNG_INTEL_SSE_OPT], [1], - [Enable Intel SSE optimizations]) - ;; - powerpc*|ppc64*) - enable_powerpc_vsx=yes - AC_DEFINE([PNG_POWERPC_VSX_OPT], [2], - [Enable POWERPC VSX optimizations]) - ;; - loongarch*) - enable_loongarch_lsx=yes - AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1], - [Enable LOONGARCH_LSX optimizations]) - ;; - esac ;; esac]) -# ARM NEON -# ======== - -AC_ARG_ENABLE([arm-neon], - AS_HELP_STRING([[[--enable-arm-neon]]], - [Enable ARM NEON optimizations: =no/off, check, api, yes/on.] - [no/off: disable the optimizations;] - [check: use internal checking code (deprecated and poorly supported);] - [api: disable by default, enable by a call to png_set_option;] - [yes/on: turn on unconditionally.] - [If not specified: determined by the compiler.]), - [case "$enableval" in - no|off) - # disable the default enabling on __ARM_NEON__ systems: - AC_DEFINE([PNG_ARM_NEON_OPT], [0], - [Disable ARM Neon optimizations]) - # Prevent inclusion of the assembler files below: - enable_arm_neon=no ;; - check) - AC_DEFINE([PNG_ARM_NEON_CHECK_SUPPORTED], [], - [Check for ARM Neon support at run-time]);; - api) - AC_DEFINE([PNG_ARM_NEON_API_SUPPORTED], [], - [Turn on ARM Neon optimizations at run-time]);; - yes|on) - AC_DEFINE([PNG_ARM_NEON_OPT], [2], - [Enable ARM Neon optimizations]) - AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api';] - [if you want the optimizations unconditionally,] - [pass '-mfpu=neon' to the compiler.]);; - *) - AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}:] - [invalid argument]) - esac]) - -# Add ARM-specific files to all builds where $host_cpu is arm ('arm*') or -# where ARM optimizations were explicitly requested. (This allows a fallback -# if a future host CPU does not match 'arm*'.) - -AM_CONDITIONAL([PNG_ARM_NEON], - [test "$enable_arm_neon" != 'no' && - case "$host_cpu" in - arm*|aarch64*) : ;; - *) test "$enable_arm_neon" != '' ;; - esac]) - -# MIPS MSA -# ======== - -AC_ARG_ENABLE([mips-msa], - AS_HELP_STRING([[[--enable-mips-msa]]], - [Enable MIPS MSA optimizations: =no/off, check, api, yes/on.] - [no/off: disable the optimizations;] - [check: use internal checking code (deprecated and poorly supported);] - [api: disable by default, enable by a call to png_set_option;] - [yes/on: turn on unconditionally.] - [If not specified: determined by the compiler.]), - [case "$enableval" in - no|off) - # disable the default enabling on __mips_msa systems: - AC_DEFINE([PNG_MIPS_MSA_OPT], [0], - [Disable MIPS MSA optimizations]) - # Prevent inclusion of the assembler files below: - enable_mips_msa=no ;; - check) - AC_DEFINE([PNG_MIPS_MSA_CHECK_SUPPORTED], [], - [Check for MIPS MSA support at run-time]);; - api) - AC_DEFINE([PNG_MIPS_MSA_API_SUPPORTED], [], - [Turn on MIPS MSA optimizations at run-time]);; - yes|on) - AC_DEFINE([PNG_MIPS_MSA_OPT], [2], - [Enable MIPS MSA optimizations]) - AC_MSG_WARN([--enable-mips-msa: please specify 'check' or 'api';] - [if you want the optimizations unconditionally,] - [pass '-mmsa -mfp64' to the compiler.]);; - *) - AC_MSG_ERROR([--enable-mips-msa=${enable_mips_msa}:] - [invalid argument]) - esac]) - -# Add MIPS-specific files to all builds where $host_cpu is mips ('mips*') or -# where MIPS optimizations were explicitly requested. (This allows a fallback -# if a future host CPU does not match 'mips*'.) - -AM_CONDITIONAL([PNG_MIPS_MSA], - [test "$enable_mips_msa" != 'no' && - case "$host_cpu" in - mipsel*|mips64el*) : ;; - esac]) - -# MIPS MMI -# ======== - -AC_ARG_ENABLE([mips-mmi], - AS_HELP_STRING([[[--enable-mips-mmi]]], - [Enable MIPS MMI optimizations: =no/off, check, api, yes/on.] - [no/off: disable the optimizations;] - [check: use internal checking code (deprecated and poorly supported);] - [api: disable by default, enable by a call to png_set_option;] - [yes/on: turn on unconditionally.] - [If not specified: determined by the compiler.]), - [case "$enableval" in - no|off) - # disable the default enabling on __mips_mmi systems: - AC_DEFINE([PNG_MIPS_MMI_OPT], [0], - [Disable MIPS MMI optimizations]) - # Prevent inclusion of the assembler files below: - enable_mips_mmi=no;; - check) - AC_DEFINE([PNG_MIPS_MMI_CHECK_SUPPORTED], [], - [Check for MIPS MMI support at run-time]);; - api) - AC_DEFINE([PNG_MIPS_MMI_API_SUPPORTED], [], - [Turn on MIPS MMI optimizations at run-time]);; - yes|on) - AC_DEFINE([PNG_MIPS_MMI_OPT], [1], - [Enable MIPS MMI optimizations]) - AC_MSG_WARN([--enable-mips-mmi: please specify 'check' or 'api';] - [if you want the optimizations unconditionally] - [pass '-mloongson-mmi -march=loongson3a' to the compiler.]);; - *) - AC_MSG_ERROR([--enable-mips-mmi=${enable_mips_mmi}:] - [invalid argument]) - esac]) - -# 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 future host CPU does not match 'mips*'.) - -AM_CONDITIONAL([PNG_MIPS_MMI], - [test "$enable_mips_mmi" != 'no' && - case "$host_cpu" in - mipsel*|mips64el*) : ;; - esac]) - -# INTEL SSE -# ========= - -AC_ARG_ENABLE([intel-sse], - AS_HELP_STRING([[[--enable-intel-sse]]], - [Enable Intel SSE optimizations: =no/off, yes/on.] - [no/off: disable the optimizations;] - [yes/on: enable the optimizations.] - [If not specified: determined by the compiler.]), - [case "$enableval" in - no|off) - # disable the default enabling: - AC_DEFINE([PNG_INTEL_SSE_OPT], [0], - [Disable Intel SSE optimizations]) - # Prevent inclusion of the assembler files below: - enable_intel_sse=no ;; - yes|on) - AC_DEFINE([PNG_INTEL_SSE_OPT], [1], - [Enable Intel SSE optimizations]);; - *) - AC_MSG_ERROR([--enable-intel-sse=${enable_intel_sse}:] - [invalid argument]) - esac]) - -# Add Intel-specific files to all builds where $host_cpu is Intel ('x86*') or -# where Intel optimizations were explicitly requested. (This allows a fallback -# if a future host CPU does not match 'x86*'.) -AM_CONDITIONAL([PNG_INTEL_SSE], - [test "$enable_intel_sse" != 'no' && - case "$host_cpu" in - i?86|x86_64) : ;; - *) test "$enable_intel_sse" != '' ;; - esac]) - -# POWERPC VSX -# =========== - -AC_ARG_ENABLE([powerpc-vsx], -AS_HELP_STRING([[[--enable-powerpc-vsx]]], - [Enable POWERPC VSX optimizations: =no/off, check, api, yes/on.] - [no/off: disable the optimizations;] - [check: use internal checking code;] - [api: disable by default, enable by a call to png_set_option;] - [yes/on: turn on unconditionally.] - [If not specified: determined by the compiler.]), - [case "$enableval" in - no|off) - # disable the default enabling on __ppc64__ systems: - AC_DEFINE([PNG_POWERPC_VSX_OPT], [0], - [Disable POWERPC VSX optimizations]) - # Prevent inclusion of the platform-specific files below: - enable_powerpc_vsx=no ;; - check) - AC_DEFINE([PNG_POWERPC_VSX_CHECK_SUPPORTED], [], - [Check for POWERPC VSX support at run-time]) - AC_MSG_WARN([--enable-powerpc-vsx: please see contrib/powerpc/README] - [for the list of supported systems.]);; - api) - AC_DEFINE([PNG_POWERPC_VSX_API_SUPPORTED], [], - [Turn on POWERPC VSX optimizations at run-time]);; - yes|on) - AC_DEFINE([PNG_POWERPC_VSX_OPT], [2], - [Enable POWERPC VSX optimizations]) - AC_MSG_WARN([--enable-powerpc-vsx: please specify 'check' or 'api';] - [if you want the optimizations unconditionally,] - [pass '-maltivec -mvsx' or '-mcpu=power8' to the compiler.]);; - *) - AC_MSG_ERROR([--enable-powerpc-vsx=${enable_powerpc_vsx}:] - [invalid argument]) - esac]) - -# Add PowerPC-specific files to all builds where $host_cpu is powerpc -# ('powerpc*') or where PowerPC optimizations were explicitly requested. -# (This allows a fallback if a future host CPU does not match 'powerpc*'.) - -AM_CONDITIONAL([PNG_POWERPC_VSX], - [test "$enable_powerpc_vsx" != 'no' && - case "$host_cpu" in - powerpc*|ppc64*) : ;; - esac]) - -# LOONGARCH LSX -# ============= - -AC_ARG_ENABLE([loongarch-lsx], - AS_HELP_STRING([[[--enable-loongarch-lsx]]], - [Enable LOONGARCH LSX optimizations: =no/off, yes/on:] - [no/off: disable the optimizations;] - [yes/on: turn on unconditionally.] - [If not specified: determined by the compiler.]), - [case "$enableval" in - no|off) - # disable the default enabling on __loongarch_simd systems: - AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [0], - [Disable LOONGARCH LSX optimizations]) - # Prevent inclusion of the assembler files below: - enable_loongarch_lsx=no;; - yes|on) - AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1], - [Enable LOONGARCH LSX optimizations]) - ;; - *) - AC_MSG_ERROR([--enable-loongarch-lsx=${enable_loongarch_lsx}:] - [invalid argument]) - esac]) - -if test "$enable_loongarch_lsx" != "no" && - 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 -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 - AC_MSG_WARN([Compiler does not support loongarch LSX.]) - fi -fi - -# Add LoongArch specific files to all builds where the host_cpu is loongarch -# ('loongarch*') or where LoongArch optimizations were explicitly requested. -# (This allows a fallback if a future host CPU does not match 'loongarch*'.) - -AM_CONDITIONAL([PNG_LOONGARCH_LSX], - [test "$enable_loongarch_lsx" != "no" && - test "$compiler_support_loongarch_lsx" = "yes" && - case "$host_cpu" in - loongarch*) : ;; - *) test "$enable_loongarch_lsx" != '' ;; - esac]) - AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]]) # Config files, substituting as above diff --git a/pngpriv.h b/pngpriv.h index 79de6e9e92..051a77ee92 100644 --- a/pngpriv.h +++ b/pngpriv.h @@ -187,7 +187,6 @@ #endif #ifndef PNG_INTEL_SSE_OPT -# ifdef PNG_INTEL_SSE /* Only check for SSE if the build configuration has been modified to * enable SSE optimizations. This means that these optimizations will * be off by default. See contrib/intel for more details. @@ -201,7 +200,6 @@ # endif # else # define PNG_INTEL_SSE_OPT 0 -# endif #endif #if PNG_INTEL_SSE_OPT > 0