Is there a way to divide by a SIMDRegister? Like can I calculate 1/SIMDReg somehow, or do anybody know about a good workaround?
There’s div in SSE but not in NEON so that’s probably why it’s not supported in SIMDRegister.
If you’re only building for SSE devices than you could just put in the / operators in SIMDRegister.
That or this will work without changing JUCE code:
SIMDRegister<float> quotient = _mm_div_ps(numerator.value, denominator.value);
thank you, that’s perfect and works nicely!
Genuine question (showing my naiveté)– why can’t the
SIMDRegister type implement a
operator/= which when built against SSE uses
_mm_div_ps, and when built against NEON or AVX has a workaround implementation which unpacks the register, performs the division operation for each value, packs the newly acquired values back into the register, then returns?
Obviously, I’m assuming, that would be a performance hit, but if you’re building against NEON, trying to use the SIMDRegister type, and need a
1/x division operation, wouldn’t you have to write something just like this anyway?
imho the proper solution would be to support division on SSE platforms and have a compile error on NEON. Trusting a user to know and understand the differences between SIMD platforms kind of defeats the purpose of hiding it behind an API.
That’s fair; I would support that solution.