From 3139ac497f434f9daebb3db8b4cb062d6a739296 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Mon, 24 Mar 2014 16:47:21 +0100 Subject: [PATCH] Improve ARM fastmode setting, probably correct now. --- math/math_util.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/math/math_util.cpp b/math/math_util.cpp index 1ae1cbfc13..4c3e0f0f02 100644 --- a/math/math_util.cpp +++ b/math/math_util.cpp @@ -14,15 +14,22 @@ void EnableFZ() { //printf("ARM FPSCR: %08x\n",x); } +// New fastmode code from: http://pandorawiki.org/Floating_Point_Optimization +// These settings turbocharge the slow VFP unit on Cortex-A8 based chips by setting +// restrictions that permit running VFP instructions on the NEON unit. +// Denormal flush-to-zero, for example. void FPU_SetFastMode() { - int x; - asm( - "fmrx %[result],FPSCR \r\n" - "orr %[result],%[result],#50331648 \r\n" // 3 << 24 - "fmxr FPSCR,%[result]" - :[result] "=r" (x) : : + static const unsigned int x = 0x04086060; + static const unsigned int y = 0x03000000; + int r; + asm volatile ( + "fmrx %0, fpscr \n\t" //r0 = FPSCR + "and %0, %0, %1 \n\t" //r0 = r0 & 0x04086060 + "orr %0, %0, %2 \n\t" //r0 = r0 | 0x03000000 + "fmxr fpscr, %0 \n\t" //FPSCR = r0 + : "=r"(r) + : "r"(x), "r"(y) ); - //printf("ARM FPSCR: %08x\n",x); } #else