Commit dc0e6cc0 authored by Evan Ramos's avatar Evan Ramos
Browse files

Clean up ksqrtasm_old to avoid compiler mis-optimizations

parent 82b94a72
......@@ -197,7 +197,7 @@ extern uint16_t ATTRIBUTE((used)) sqrtable[4096], ATTRIBUTE((used)) shlookup[409
return (((d<<4)^0xf0)|d);
}
inline int32_t getkensmessagecrc(int32_t b)
static inline int32_t getkensmessagecrc(int32_t b)
{
UNREFERENCED_PARAMETER(b);
return 0x56c764d4l;
......@@ -205,17 +205,20 @@ extern uint16_t ATTRIBUTE((used)) sqrtable[4096], ATTRIBUTE((used)) shlookup[409
#endif
inline int32_t ksqrtasm_old(int32_t n)
static inline int32_t ksqrtasm_old(int32_t n)
{
n = klabs(n);
int shift;
for (shift = 0; n >= 2048; n >>=2, shift++)
uint32_t u = klabs(n);
uint32_t shift = 0;
while (u >= 2048)
{
u >>= 2;
++shift;
}
return (sqrtable_old[n]<<shift)>>10;
uint32_t const s = sqrtable_old[u];
return (s << shift) >> 10;
}
inline int32_t clip_nsqrtasm(int32_t n)
static inline int32_t clip_nsqrtasm(int32_t n)
{
if (enginecompatibilitymode == ENGINE_19950829)
return ksqrtasm_old(n);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment