mirror of
https://gitlab.com/80486DX2-66/gists
synced 2025-01-10 17:32:05 +05:30
opt_int_div.h: add optimization for case abs(a) < abs(b)
This commit is contained in:
parent
fef612cec2
commit
3c9278f472
@ -33,6 +33,10 @@
|
|||||||
/* the result is +/-1 */ \
|
/* the result is +/-1 */ \
|
||||||
(INT_DIV_NEG_RESULT_SIGN(a, b) ? -1 : 1) : ( \
|
(INT_DIV_NEG_RESULT_SIGN(a, b) ? -1 : 1) : ( \
|
||||||
\
|
\
|
||||||
|
/* check if abs(a) < abs(b) */ \
|
||||||
|
INT_ABS((a)) < INT_ABS((b)) ? \
|
||||||
|
0 : ( \
|
||||||
|
\
|
||||||
/* check if b is a power of 2 */ \
|
/* check if b is a power of 2 */ \
|
||||||
/* */ \
|
/* */ \
|
||||||
/* formula: round(log_2(b) % 1, OPT_INT_DIV_TEST_PRECISION digits */ \
|
/* formula: round(log_2(b) % 1, OPT_INT_DIV_TEST_PRECISION digits */ \
|
||||||
@ -44,5 +48,5 @@
|
|||||||
: \
|
: \
|
||||||
INT_BIN_DIV(INT_ABS(a), INT_ABS(b))) \
|
INT_BIN_DIV(INT_ABS(a), INT_ABS(b))) \
|
||||||
: \
|
: \
|
||||||
((a) / (b)) ) \
|
((a) / (b)) )) \
|
||||||
) /* end */
|
) /* end */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user