1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Removed some legacy support for non-SSE2 CPUs. Added function FloatVectorOperations::disableDenormalisedNumberSupport()

This commit is contained in:
jules 2016-03-01 16:32:08 +00:00
parent 889a6e200f
commit beac2e4b3a
2 changed files with 15 additions and 22 deletions

View file

@ -29,17 +29,6 @@ namespace FloatVectorHelpers
#define JUCE_INCREMENT_DEST dest += (16 / sizeof (*dest));
#if JUCE_USE_SSE_INTRINSICS
static bool sse2Present = false;
static bool isSSE2Available() noexcept
{
if (sse2Present)
return true;
sse2Present = SystemStats::hasSSE2();
return sse2Present;
}
inline static bool isAligned (const void* p) noexcept
{
return (((pointer_sized_int) p) & 15) == 0;
@ -113,7 +102,6 @@ namespace FloatVectorHelpers
#define JUCE_BEGIN_VEC_OP \
typedef FloatVectorHelpers::ModeType<sizeof(*dest)>::Mode Mode; \
if (FloatVectorHelpers::isSSE2Available()) \
{ \
const int numLongOps = num / Mode::numParallel;
@ -372,11 +360,7 @@ namespace FloatVectorHelpers
{
int numLongOps = num / Mode::numParallel;
#if JUCE_USE_SSE_INTRINSICS
if (numLongOps > 1 && isSSE2Available())
#else
if (numLongOps > 1)
#endif
{
ParallelType val;
@ -446,11 +430,7 @@ namespace FloatVectorHelpers
{
int numLongOps = num / Mode::numParallel;
#if JUCE_USE_SSE_INTRINSICS
if (numLongOps > 1 && isSSE2Available())
#else
if (numLongOps > 1)
#endif
{
ParallelType mn, mx;
@ -1002,12 +982,19 @@ double JUCE_CALLTYPE FloatVectorOperations::findMaximum (const double* src, int
void JUCE_CALLTYPE FloatVectorOperations::enableFlushToZeroMode (bool shouldEnable) noexcept
{
#if JUCE_USE_SSE_INTRINSICS
if (FloatVectorHelpers::isSSE2Available())
_MM_SET_FLUSH_ZERO_MODE (shouldEnable ? _MM_FLUSH_ZERO_ON : _MM_FLUSH_ZERO_OFF);
_MM_SET_FLUSH_ZERO_MODE (shouldEnable ? _MM_FLUSH_ZERO_ON : _MM_FLUSH_ZERO_OFF);
#endif
ignoreUnused (shouldEnable);
}
void JUCE_CALLTYPE FloatVectorOperations::disableDenormalisedNumberSupport() noexcept
{
#if JUCE_USE_SSE_INTRINSICS
const int mxcsr = _mm_getcsr();
_mm_setcsr (mxcsr | 0x8040); // add the DAZ and FZ bits
#endif
}
//==============================================================================
//==============================================================================
#if JUCE_UNIT_TESTS

View file

@ -198,6 +198,12 @@ public:
Effectively, this is a wrapper around a call to _MM_SET_FLUSH_ZERO_MODE
*/
static void JUCE_CALLTYPE enableFlushToZeroMode (bool shouldEnable) noexcept;
/** On Intel CPUs, this method enables the SSE flush-to-zero and denormalised-are-zero modes.
This effectively sets the DAZ and FZ bits of the MXCSR register. It's a convenient thing to
call before audio processing code where you really want to avoid denormalisation performance hits.
*/
static void JUCE_CALLTYPE disableDenormalisedNumberSupport() noexcept;
};