mruby-bigint: Extend Barrett reduction range to 16 limbs

Extended the range for Barrett reduction in mpz_mod from 8 to 16 limbs.
This allows the more efficient Barrett reduction algorithm to be used
for a wider range of moduli, improving performance for modular
arithmetic operations.

Co-authored-by: Gemini <gemini@google.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-07-31 10:11:18 +09:00
parent bcbcef4203
commit 40bf859fa2
+1 -1
View File
@@ -1694,7 +1694,7 @@ mpz_mod(mpz_ctx_t *ctx, mpz_t *r, mpz_t *x, mpz_t *y)
}
/* Barrett reduction for moderate-sized moduli */
if (y->sz >= 2 && y->sz <= 8 && x->sz >= y->sz + 2) {
if (y->sz >= 2 && y->sz <= 16 && x->sz >= y->sz + 2) {
mpz_t mu;
mpz_init_temp(ctx, &mu, y->sz + 1);
mpz_barrett_mu(ctx, &mu, y);