1
0
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:
パチュリー・ノーレッジ 2024-03-09 17:51:22 +03:00
parent fef612cec2
commit 3c9278f472
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B

View File

@ -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 */