From c200c16a49c3dd52007022ee2322b4fbef751496 Mon Sep 17 00:00:00 2001 From: "Michael R. Crusoe" Date: Wed, 21 Feb 2024 14:16:08 +0100 Subject: [PATCH] arm/neon abs: negating INT_MIN is undefined behavior - So cast to unsigned int before flipping sign, and then cast back to a signed int LLVM 19 is making this more prominant: https://github.com/llvm/llvm-project/issues/82112#issuecomment-1956469212 But this was already visible in earlier clang versions with `-O2` https://github.com/simd-everywhere/simde/issues/901 - gh-actions: resume testing emscripten using the 'tip of tree' ("tot") builds. - gh-actions: add clang-17 "-O2" build to confirm the fix --- .github/workflows/ci.yml | 7 +++++-- docker/cross-files/i686-gcc-14.cross | 17 +++++++++++++++++ simde/arm/neon/abs.h | 4 ++-- 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 docker/cross-files/i686-gcc-14.cross diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bcf706b74..e34d4da64 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -168,8 +168,8 @@ jobs: run: | git clone https://github.com/emscripten-core/emsdk.git /opt/emsdk cd /opt/emsdk - ./emsdk install 4e7eadf19c76c143e522b535254eb99a9b34fd6d - ./emsdk activate 4e7eadf19c76c143e522b535254eb99a9b34fd6d + ./emsdk install tot + ./emsdk activate tot source emsdk_env.sh - name: Install v8 run: | @@ -532,6 +532,9 @@ jobs: distro: ubuntu-22.04 arch_flags: -ffast-math -Wno-unsafe-buffer-usage ccache: 'true' + - version: "17" + distro: ubuntu-22.04 + arch_flags: -march=native -Wno-unsafe-buffer-usage -O2 runs-on: ${{ matrix.distro }} env: CFLAGS: ${{ matrix.arch_flags }} -Wall -Weverything -Werror -fno-lax-vector-conversions diff --git a/docker/cross-files/i686-gcc-14.cross b/docker/cross-files/i686-gcc-14.cross new file mode 100644 index 000000000..9fe67d5ca --- /dev/null +++ b/docker/cross-files/i686-gcc-14.cross @@ -0,0 +1,17 @@ +[binaries] +c = 'i686-linux-gnu-gcc-14' +cpp = 'i686-linux-gnu-g++-14' +ar = 'i686-linux-gnu-ar' +strip = 'i686-linux-gnu-strip' +objcopy = 'i686-linux-gnu-objcopy' +ld = 'i686-linux-gnu-ld' + +[properties] +c_args = ['-Wextra', '-Werror', '-march=prescott'] +cpp_args = ['-Wextra', '-Werror', '-march=prescott'] + +[host_machine] +system = 'linux' +cpu_family = 'x86' +cpu = 'prescott' +endian = 'little' diff --git a/simde/arm/neon/abs.h b/simde/arm/neon/abs.h index 982bed9cc..16250da78 100644 --- a/simde/arm/neon/abs.h +++ b/simde/arm/neon/abs.h @@ -437,7 +437,7 @@ simde_vabsq_s32(simde_int32x4_t a) { #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) { - r_.values[i] = a_.values[i] < 0 ? -a_.values[i] : a_.values[i]; + r_.values[i] = a_.values[i] < 0 ? HEDLEY_STATIC_CAST(int32_t, 0 - HEDLEY_STATIC_CAST(uint32_t, a_.values[i])) : a_.values[i]; } #endif @@ -476,7 +476,7 @@ simde_vabsq_s64(simde_int64x2_t a) { #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) { - r_.values[i] = a_.values[i] < 0 ? -a_.values[i] : a_.values[i]; + r_.values[i] = a_.values[i] < 0 ? HEDLEY_STATIC_CAST(int64_t, 0 - HEDLEY_STATIC_CAST(uint64_t, a_.values[i])) : a_.values[i]; } #endif