diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 6fe7779a7..0940742df 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -119,7 +119,7 @@ jobs: CMAKE_EXTRA_ARGS="$CMAKE_EXTRA_ARGS -DTARGET_ARCH=knm" fi if [[ '${{ matrix.sys.flags }}' == 'i386' ]]; then - CXX_FLAGS="$CXX_FLAGS -m32" + CXXFLAGS="$CXXFLAGS -m32" fi if [[ '${{ matrix.sys.flags }}' == 'force_no_instr_set' ]]; then : @@ -128,17 +128,19 @@ jobs: fi # Cheap way of spotting uninitialized read - CXX_FLAGS="$CXX_FLAGS -ftrivial-auto-var-init=pattern" + if echo 'int main(){}' | $CXX -x c++ -ftrivial-auto-var-init=pattern -fsyntax-only - 2>/dev/null; then + CXXFLAGS="$CXXFLAGS -ftrivial-auto-var-init=pattern" + fi cmake -B _build \ -DBUILD_TESTS=ON \ - -DBUILD_BENCHMARK=ON \ -DBUILD_EXAMPLES=ON \ + -DBUILD_ARCHITECTURE_TESTS=OFF \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_C_COMPILER=$CC \ -DCMAKE_CXX_COMPILER=$CXX \ $CMAKE_EXTRA_ARGS \ - -DCMAKE_CXX_FLAGS='$CXX_FLAGS' \ + -DCMAKE_CXX_FLAGS="$CXXFLAGS" \ -G Ninja - name: Build run: cmake --build _build @@ -161,3 +163,33 @@ jobs: export XSIMD_TEST_CPU_ASSUME_MANUFACTURER="intel,amd" ./test_xsimd fi + + build-extra: + runs-on: ubuntu-latest + name: 'clang 18 - architectures and benchmark' + steps: + - name: Setup compiler + run: | + sudo apt-get update || exit 1 + sudo apt-get --no-install-suggests --no-install-recommends install clang-18 || exit 1 + echo "CC=clang-18" >> $GITHUB_ENV + echo "CXX=clang++-18" >> $GITHUB_ENV + - name: Checkout xsimd + uses: actions/checkout@v6 + - name: Install mamba + uses: mamba-org/setup-micromamba@v2 + with: + environment-file: environment.yml + - name: Configure build + run: | + cmake -B _build \ + -DBUILD_TESTS=ON \ + -DBUILD_ARCHITECTURE_TESTS=ON \ + -DBUILD_BENCHMARK=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER=$CC \ + -DCMAKE_CXX_COMPILER=$CXX \ + -DXSIMD_ENABLE_WERROR=ON \ + -G Ninja + - name: Build + run: cmake --build _build diff --git a/include/xsimd/arch/xsimd_avx.hpp b/include/xsimd/arch/xsimd_avx.hpp index 84b1ba3a0..49bd12b90 100644 --- a/include/xsimd/arch/xsimd_avx.hpp +++ b/include/xsimd/arch/xsimd_avx.hpp @@ -1726,12 +1726,12 @@ namespace xsimd { return ssub(batch(s), batch(o)); }, self, other); } - else if (std::is_signed_v) + else if constexpr (std::is_signed_v) { - auto mask = (other >> (8 * sizeof(T) - 1)); + auto other_is_negative = other < batch(T(0)); auto self_overflow_branch = min(std::numeric_limits::max() + other, self); auto self_underflow_branch = max(std::numeric_limits::min() + other, self); - return select(batch_bool(mask.data), self_overflow_branch, self_underflow_branch) - other; + return select(other_is_negative, self_overflow_branch, self_underflow_branch) - other; } else { diff --git a/include/xsimd/arch/xsimd_avx512f.hpp b/include/xsimd/arch/xsimd_avx512f.hpp index 02934de8b..e5ab27813 100644 --- a/include/xsimd/arch/xsimd_avx512f.hpp +++ b/include/xsimd/arch/xsimd_avx512f.hpp @@ -1561,7 +1561,7 @@ namespace xsimd const uint32_t magic = (0x80 + 0x4000 + 0x200000 + 0x10000000); - unsigned char res = ((data * magic) >> 24) & 0xFF; + unsigned char res = (data * magic) >> 28; return res; } else if constexpr (N == 2) @@ -1571,7 +1571,7 @@ namespace xsimd const uint16_t magic = (0x80 + 0x4000); - unsigned char res = ((data * magic) >> 8) & 0xFF; + unsigned char res = (data * magic) >> 14; return res; } } diff --git a/include/xsimd/arch/xsimd_common_fwd.hpp b/include/xsimd/arch/xsimd_common_fwd.hpp index b247b2bd6..139b0b282 100644 --- a/include/xsimd/arch/xsimd_common_fwd.hpp +++ b/include/xsimd/arch/xsimd_common_fwd.hpp @@ -60,6 +60,10 @@ namespace xsimd XSIMD_INLINE batch bitwise_rshift(batch const& self, batch const& other, requires_arch) noexcept; template >> XSIMD_INLINE batch bitwise_rshift(batch const& self, requires_arch) noexcept; + template + XSIMD_INLINE batch decr_if(batch const& self, Mask const& mask, requires_arch) noexcept; + template + XSIMD_INLINE batch incr_if(batch const& self, Mask const& mask, requires_arch) noexcept; template XSIMD_INLINE batch_bool gt(batch const& self, batch const& other, requires_arch) noexcept; template >> diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 003d31201..fca96de7f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -218,7 +218,10 @@ if (XSIMD_ENABLE_WERROR) endif() add_subdirectory(doc) -add_subdirectory(architectures) +OPTION(BUILD_ARCHITECTURE_TESTS "xsimd compilation tests for various -march targets" ON) +if(BUILD_ARCHITECTURE_TESTS) + add_subdirectory(architectures) +endif() if(EMULATED_COMPILE_FLAGS) message(STATUS ${EMULATED_COMPILE_FLAGS})