Commit 22a493c2 authored by Michael R. Crusoe's avatar Michael R. Crusoe Committed by Michael R. Crusoe

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
parent 453dec20
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment