arm: flush denormals to zero (#1696)

This commit is contained in:
SamoZ256
2025-09-27 00:41:17 +02:00
committed by GitHub
parent 84f12eea65
commit d54fb0ba78

View File

@@ -15,6 +15,33 @@
#include "util/helpers/helpers.h"
#ifdef __arm64__
#if defined(__clang__)
#include <arm_acle.h>
#elif defined(_MSC_VER)
#include <intrin.h>
#endif
#endif
namespace {
void enableFlushDenormalsToZero()
{
#if defined(ARCH_X86_64)
_mm_setcsr(_mm_getcsr() | 0x8000);
#elif defined(__arm64__)
#if defined(__clang__)
__arm_wsr64("fpcr", __arm_rsr64("fpcr") | (1 << 24));
#elif defined(__GNUC__)
__builtin_aarch64_set_fpcr(__builtin_aarch64_get_fpcr() | (1 << 24));
#elif defined(_MSC_VER)
_WriteStatusReg(ARM64_FPCR, _ReadStatusReg(ARM64_FPCR) | (1 << 24));
#endif
#endif
}
}
SlimRWLock srwlock_activeThreadList;
// public list of active threads
@@ -1321,9 +1348,7 @@ namespace coreinit
#endif
OSHostThread* hostThread = (OSHostThread*)_thread;
#if defined(ARCH_X86_64)
_mm_setcsr(_mm_getcsr() | 0x8000); // flush denormals to zero
#endif
enableFlushDenormalsToZero();
PPCInterpreter_t* hCPU = &hostThread->ppcInstance;
__OSLoadThread(hostThread->m_thread, hCPU, hostThread->selectedCore);
@@ -1369,9 +1394,8 @@ namespace coreinit
{
SetThreadName(fmt::format("OSSched[core={}]", (uintptr_t)_assignedCoreIndex).c_str());
t_assignedCoreIndex = (sint32)(uintptr_t)_assignedCoreIndex;
#if defined(ARCH_X86_64)
_mm_setcsr(_mm_getcsr() | 0x8000); // flush denormals to zero
#endif
enableFlushDenormalsToZero();
#if BOOST_OS_LINUX
if (g_gdbstub)