diff options
author | Andy Polyakov <appro@openssl.org> | 1999-07-30 11:43:43 +0000 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 1999-07-30 11:43:43 +0000 |
commit | 0dd25e3606f767381de8c8722b76f813c8e3b013 (patch) | |
tree | 7d1d8e5a80e41a637c3321907a9d890dcc006e2c /crypto/bn/bn_asm.c | |
parent | a40f6dce871e8e020ca16713cc19798fcc141ed1 (diff) |
Bignum division tune-up. Idea is to move multiplications in front of
loop body and replace 'em with addition/subtraction.
Diffstat (limited to 'crypto/bn/bn_asm.c')
-rw-r--r-- | crypto/bn/bn_asm.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/crypto/bn/bn_asm.c b/crypto/bn/bn_asm.c index 286a0f1e74..4d3da16a0c 100644 --- a/crypto/bn/bn_asm.c +++ b/crypto/bn/bn_asm.c @@ -264,18 +264,20 @@ BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d) else q=h/dh; + th=q*dh; + tl=dl*q; for (;;) { - t=(h-(th=q*dh)); - tl=BN_MASK2; + t=h-th; if ((t&BN_MASK2h) || - ((tl=dl*q) <= ( + ((tl) <= ( (t<<BN_BITS4)| ((l&BN_MASK2h)>>BN_BITS4)))) break; q--; + th-=dh; + tl-=dl; } - if (tl==BN_MASK2) tl=q*dl; t=(tl>>BN_BITS4); tl=(tl<<BN_BITS4)&BN_MASK2h; th+=t; |