mirror of
https://github.com/mupen64plus/mupen64plus-rsp-cxd4.git
synced 2025-04-02 10:51:55 -04:00
Conker's BFD micro-optimization with 2's cmpl. integer division
This commit is contained in:
parent
690bb76c47
commit
bf7c98f586
1 changed files with 7 additions and 0 deletions
|
@ -1070,10 +1070,17 @@ INLINE static void do_div(i32 data, int sqrt, int precision)
|
|||
int fetch;
|
||||
int shift;
|
||||
|
||||
#if (~0 >> 1 == -1)
|
||||
data ^= (s32)(data + 32768) >> 31; /* DP only: (data < -32768) */
|
||||
fetch = (s32)(data + 0) >> 31;
|
||||
data ^= fetch;
|
||||
data -= fetch; /* two's complement: -x == ~x - (~0) on wrap-around */
|
||||
#else
|
||||
if (precision == SP_DIV_PRECISION_SINGLE)
|
||||
data = (data < 0) ? -data : +data;
|
||||
if (precision == SP_DIV_PRECISION_DOUBLE && data < 0)
|
||||
data = (data >= -32768) ? -data : ~data;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Note, from the code just above, that data cannot be negative.
|
||||
|
|
Loading…
Add table
Reference in a new issue