Commit d95bd9d7 authored by Russell Graves's avatar Russell Graves Committed by GitHub

arm neon qdmull: Fix SQDMULL implementation for 32-bit inputs. (#1255)

The non-vectorized SQDMULL implementation was wrong for 32-bit
inputs.  It incorrectly checked one of the operands to see if the
value would overflow before doubling it, not the result of the
initial multiplication.  It now matches the 16-bit operand version,
and also matches hardware.  A test has been added for the scalar
form of the function, testing a range of values that will saturate
when multiplied and doubled.  This set of test vectors was produced
on an ARMv9 machine (Google Cloud box), failed tests on x86 with the
existing code, and passes with the modified code.
parent 4b900704
...@@ -65,7 +65,7 @@ simde_vqdmulls_s32(int32_t a, int32_t b) { ...@@ -65,7 +65,7 @@ simde_vqdmulls_s32(int32_t a, int32_t b) {
return vqdmulls_s32(a, b); return vqdmulls_s32(a, b);
#else #else
int64_t mul = (HEDLEY_STATIC_CAST(int64_t, a) * HEDLEY_STATIC_CAST(int64_t, b)); int64_t mul = (HEDLEY_STATIC_CAST(int64_t, a) * HEDLEY_STATIC_CAST(int64_t, b));
return ((a > 0 ? a : -a) & (HEDLEY_STATIC_CAST(int64_t, 1) << 62)) ? ((mul < 0) ? INT64_MIN : INT64_MAX) : mul << 1; return (simde_math_llabs(mul) & (HEDLEY_STATIC_CAST(int64_t, 1) << 62)) ? ((mul < 0) ? INT64_MIN : INT64_MAX) : mul << 1;
#endif #endif
} }
#if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES) #if defined(SIMDE_ARM_NEON_A32V7_ENABLE_NATIVE_ALIASES)
......
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