diff --git a/modules/juce_dsp/containers/juce_SIMDRegister_test.cpp b/modules/juce_dsp/containers/juce_SIMDRegister_test.cpp index c84e34ed23..5b13b63a21 100644 --- a/modules/juce_dsp/containers/juce_SIMDRegister_test.cpp +++ b/modules/juce_dsp/containers/juce_SIMDRegister_test.cpp @@ -652,6 +652,43 @@ public: } }; + struct CheckBoolEquals + { + template + static void run (UnitTest& u, Random& random) + { + bool is_signed = std::is_signed::value; + type array [SIMDRegister::SIMDNumElements]; + + auto value = is_signed ? static_cast ((random.nextFloat() * 16.0) - 8.0) + : static_cast (random.nextFloat() * 8.0); + + std::fill (array, array + SIMDRegister::SIMDNumElements, value); + SIMDRegister a, b; + copy (a, array); + + u.expect (a == value); + u.expect (! (a != value)); + value += 1; + + u.expect (a != value); + u.expect (! (a == value)); + + SIMDRegister_test_internal::fillRandom (array, SIMDRegister::SIMDNumElements, random); + copy (a, array); + copy (b, array); + + u.expect (a == b); + u.expect (! (a != b)); + + SIMDRegister_test_internal::fillRandom (array, SIMDRegister::SIMDNumElements, random); + copy (b, array); + + u.expect (a != b); + u.expect (! (a == b)); + } + }; + //============================================================================== template void runTestForAllTypes (const char* unitTestName) @@ -708,6 +745,7 @@ public: runTestForAllTypes> ("BitXOROperators"); runTestNonComplex ("CheckComparisons"); + runTestNonComplex ("CheckBoolEquals"); runTestNonComplex ("CheckMinMax"); runTestForAllTypes ("CheckMultiplyAdd"); diff --git a/modules/juce_dsp/native/juce_avx_SIMDNativeOps.h b/modules/juce_dsp/native/juce_avx_SIMDNativeOps.h index 696f810e3b..c7a6b7b945 100644 --- a/modules/juce_dsp/native/juce_avx_SIMDNativeOps.h +++ b/modules/juce_dsp/native/juce_avx_SIMDNativeOps.h @@ -31,6 +31,11 @@ namespace dsp #ifndef DOXYGEN +#if JUCE_GCC + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wignored-attributes" +#endif + #ifdef _MSC_VER #define DECLARE_AVX_SIMD_CONST(type, name) \ static __declspec(align(32)) const type name[32 / sizeof (type)] @@ -700,5 +705,9 @@ struct SIMDNativeOps #endif +#if JUCE_GCC + #pragma GCC diagnostic pop +#endif + } // namespace dsp } // namespace juce diff --git a/modules/juce_dsp/native/juce_neon_SIMDNativeOps.h b/modules/juce_dsp/native/juce_neon_SIMDNativeOps.h index 2fc7b1ee48..b2c70a0bf4 100644 --- a/modules/juce_dsp/native/juce_neon_SIMDNativeOps.h +++ b/modules/juce_dsp/native/juce_neon_SIMDNativeOps.h @@ -31,6 +31,11 @@ namespace dsp #ifndef DOXYGEN +#if JUCE_GCC + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wignored-attributes" +#endif + #ifdef _MSC_VER #define DECLARE_NEON_SIMD_CONST(type, name) \ static __declspec(align(16)) const type name [16 / sizeof (type)] @@ -168,7 +173,7 @@ struct SIMDNativeOps static forcedinline vSIMDType notEqual (vSIMDType a, vSIMDType b) noexcept { return bit_not (equal (a, b)); } static forcedinline vSIMDType greaterThan (vSIMDType a, vSIMDType b) noexcept { return (vSIMDType) vcgtq_s8 (a, b); } static forcedinline vSIMDType greaterThanOrEqual (vSIMDType a, vSIMDType b) noexcept { return (vSIMDType) vcgeq_s8 (a, b); } - static forcedinline bool allEqual (vSIMDType a, vSIMDType b) noexcept { return (SIMDNativeOps::sum (notEqual (a, b)) == 0); } + static forcedinline bool allEqual (vSIMDType a, vSIMDType b) noexcept { return (SIMDNativeOps::sum ((SIMDNativeOps::vSIMDType) notEqual (a, b)) == 0); } static forcedinline vSIMDType multiplyAdd (vSIMDType a, vSIMDType b, vSIMDType c) noexcept { return vmlaq_s8 (a, b, c); } static forcedinline int8_t sum (vSIMDType a) noexcept { return fb::sum (a); } }; @@ -206,7 +211,7 @@ struct SIMDNativeOps static forcedinline vSIMDType notEqual (vSIMDType a, vSIMDType b) noexcept { return bit_not (equal (a, b)); } static forcedinline vSIMDType greaterThan (vSIMDType a, vSIMDType b) noexcept { return (vSIMDType) vcgtq_u8 (a, b); } static forcedinline vSIMDType greaterThanOrEqual (vSIMDType a, vSIMDType b) noexcept { return (vSIMDType) vcgeq_u8 (a, b); } - static forcedinline bool allEqual (vSIMDType a, vSIMDType b) noexcept { return (SIMDNativeOps::sum (notEqual (a, b)) == 0); } + static forcedinline bool allEqual (vSIMDType a, vSIMDType b) noexcept { return (SIMDNativeOps::sum ((SIMDNativeOps::vSIMDType) notEqual (a, b)) == 0); } static forcedinline vSIMDType multiplyAdd (vSIMDType a, vSIMDType b, vSIMDType c) noexcept { return vmlaq_u8 (a, b, c); } static forcedinline uint8_t sum (vSIMDType a) noexcept { return fb::sum (a); } }; @@ -244,7 +249,7 @@ struct SIMDNativeOps static forcedinline vSIMDType notEqual (vSIMDType a, vSIMDType b) noexcept { return bit_not (equal (a, b)); } static forcedinline vSIMDType greaterThan (vSIMDType a, vSIMDType b) noexcept { return (vSIMDType) vcgtq_s16 (a, b); } static forcedinline vSIMDType greaterThanOrEqual (vSIMDType a, vSIMDType b) noexcept { return (vSIMDType) vcgeq_s16 (a, b); } - static forcedinline bool allEqual (vSIMDType a, vSIMDType b) noexcept { return (SIMDNativeOps::sum (notEqual (a, b)) == 0); } + static forcedinline bool allEqual (vSIMDType a, vSIMDType b) noexcept { return (SIMDNativeOps::sum ((SIMDNativeOps::vSIMDType) notEqual (a, b)) == 0); } static forcedinline vSIMDType multiplyAdd (vSIMDType a, vSIMDType b, vSIMDType c) noexcept { return vmlaq_s16 (a, b, c); } static forcedinline int16_t sum (vSIMDType a) noexcept { return fb::sum (a); } }; @@ -283,7 +288,7 @@ struct SIMDNativeOps static forcedinline vSIMDType notEqual (vSIMDType a, vSIMDType b) noexcept { return bit_not (equal (a, b)); } static forcedinline vSIMDType greaterThan (vSIMDType a, vSIMDType b) noexcept { return (vSIMDType) vcgtq_u16 (a, b); } static forcedinline vSIMDType greaterThanOrEqual (vSIMDType a, vSIMDType b) noexcept { return (vSIMDType) vcgeq_u16 (a, b); } - static forcedinline bool allEqual (vSIMDType a, vSIMDType b) noexcept { return (SIMDNativeOps::sum (notEqual (a, b)) == 0); } + static forcedinline bool allEqual (vSIMDType a, vSIMDType b) noexcept { return (SIMDNativeOps::sum ((SIMDNativeOps::vSIMDType) notEqual (a, b)) == 0); } static forcedinline vSIMDType multiplyAdd (vSIMDType a, vSIMDType b, vSIMDType c) noexcept { return vmlaq_u16 (a, b, c); } static forcedinline uint16_t sum (vSIMDType a) noexcept { return fb::sum (a); } }; @@ -321,7 +326,7 @@ struct SIMDNativeOps static forcedinline vSIMDType notEqual (vSIMDType a, vSIMDType b) noexcept { return fb::notEqual (a, b); } static forcedinline vSIMDType greaterThan (vSIMDType a, vSIMDType b) noexcept { return fb::greaterThan (a, b); } static forcedinline vSIMDType greaterThanOrEqual (vSIMDType a, vSIMDType b) noexcept { return fb::greaterThanOrEqual (a, b); } - static forcedinline bool allEqual (vSIMDType a, vSIMDType b) noexcept { return (SIMDNativeOps::sum (notEqual (a, b)) == 0); } + static forcedinline bool allEqual (vSIMDType a, vSIMDType b) noexcept { return (SIMDNativeOps::sum ((SIMDNativeOps::vSIMDType) notEqual (a, b)) == 0); } static forcedinline vSIMDType multiplyAdd (vSIMDType a, vSIMDType b, vSIMDType c) noexcept { return fb::multiplyAdd (a, b, c); } static forcedinline int64_t sum (vSIMDType a) noexcept { return fb::sum (a); } }; @@ -360,7 +365,7 @@ struct SIMDNativeOps static forcedinline vSIMDType notEqual (vSIMDType a, vSIMDType b) noexcept { return fb::notEqual (a, b); } static forcedinline vSIMDType greaterThan (vSIMDType a, vSIMDType b) noexcept { return fb::greaterThan (a, b); } static forcedinline vSIMDType greaterThanOrEqual (vSIMDType a, vSIMDType b) noexcept { return fb::greaterThanOrEqual (a, b); } - static forcedinline bool allEqual (vSIMDType a, vSIMDType b) noexcept { return (SIMDNativeOps::sum (notEqual (a, b)) == 0); } + static forcedinline bool allEqual (vSIMDType a, vSIMDType b) noexcept { return (SIMDNativeOps::sum ((SIMDNativeOps::vSIMDType) notEqual (a, b)) == 0); } static forcedinline vSIMDType multiplyAdd (vSIMDType a, vSIMDType b, vSIMDType c) noexcept { return fb::multiplyAdd (a, b, c); } static forcedinline uint64_t sum (vSIMDType a) noexcept { return fb::sum (a); } }; @@ -401,7 +406,7 @@ struct SIMDNativeOps static forcedinline vSIMDType notEqual (vSIMDType a, vSIMDType b) noexcept { return bit_not (equal (a, b)); } static forcedinline vSIMDType greaterThan (vSIMDType a, vSIMDType b) noexcept { return (vSIMDType) vcgtq_f32 (a, b); } static forcedinline vSIMDType greaterThanOrEqual (vSIMDType a, vSIMDType b) noexcept { return (vSIMDType) vcgeq_f32 (a, b); } - static forcedinline bool allEqual (vSIMDType a, vSIMDType b) noexcept { return (SIMDNativeOps::sum (notEqual (a, b)) == 0); } + static forcedinline bool allEqual (vSIMDType a, vSIMDType b) noexcept { return (SIMDNativeOps::sum ((SIMDNativeOps::vSIMDType) notEqual (a, b)) == 0); } static forcedinline vSIMDType multiplyAdd (vSIMDType a, vSIMDType b, vSIMDType c) noexcept { return vmlaq_f32 (a, b, c); } static forcedinline vSIMDType dupeven (vSIMDType a) noexcept { return fb::shuffle<(0 << 0) | (0 << 2) | (2 << 4) | (2 << 6)> (a); } static forcedinline vSIMDType dupodd (vSIMDType a) noexcept { return fb::shuffle<(1 << 0) | (1 << 2) | (3 << 4) | (3 << 6)> (a); } @@ -462,5 +467,9 @@ struct SIMDNativeOps #endif +#if JUCE_GCC + #pragma GCC diagnostic pop +#endif + } // namespace dsp } // namespace juce diff --git a/modules/juce_dsp/native/juce_sse_SIMDNativeOps.h b/modules/juce_dsp/native/juce_sse_SIMDNativeOps.h index a11186abf9..37b308c0d4 100644 --- a/modules/juce_dsp/native/juce_sse_SIMDNativeOps.h +++ b/modules/juce_dsp/native/juce_sse_SIMDNativeOps.h @@ -31,6 +31,11 @@ namespace dsp #ifndef DOXYGEN +#if JUCE_GCC + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wignored-attributes" +#endif + #ifdef _MSC_VER #define DECLARE_SSE_SIMD_CONST(type, name) \ static __declspec(align(16)) const type name [16 / sizeof (type)] @@ -867,5 +872,9 @@ struct SIMDNativeOps #endif +#if JUCE_GCC + #pragma GCC diagnostic pop +#endif + } // namespace dsp } // namespace juce