diff options
author | Andy Polyakov <appro@openssl.org> | 2002-12-14 20:42:05 +0000 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2002-12-14 20:42:05 +0000 |
commit | 2f98abbcb6cfd6ffcf45d5587286f1f849184594 (patch) | |
tree | 890a6915ae4da1afd9ef397b6ead8ac5e8ab37e7 /crypto/bn/bn_div.c | |
parent | 270fa8aedae8595f9c95a03f019b69cffc31baee (diff) |
x86_64 performance patch.
Diffstat (limited to 'crypto/bn/bn_div.c')
-rw-r--r-- | crypto/bn/bn_div.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/crypto/bn/bn_div.c b/crypto/bn/bn_div.c index f9a095e3b3..ea099e0c2b 100644 --- a/crypto/bn/bn_div.c +++ b/crypto/bn/bn_div.c @@ -150,6 +150,20 @@ int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, q; \ }) # define REMAINDER_IS_ALREADY_CALCULATED +# elif defined(__x86_64) && defined(SIXTY_FOUR_BIT_LONG) + /* + * Same story here, but it's 128-bit by 64-bit division. Wow! + * <appro@fy.chalmers.se> + */ +# define bn_div_words(n0,n1,d0) \ + ({ asm volatile ( \ + "divq %4" \ + : "=a"(q), "=d"(rem) \ + : "a"(n1), "d"(n0), "g"(d0) \ + : "cc"); \ + q; \ + }) +# define REMAINDER_IS_ALREADY_CALCULATED # endif /* __<cpu> */ # endif /* __GNUC__ */ #endif /* OPENSSL_NO_ASM */ @@ -296,7 +310,9 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor, rem=(n1-q*d0)&BN_MASK2; #endif -#ifdef BN_UMULT_HIGH +#if defined(BN_UMULT_LOHI) + BN_UMULT_LOHI(t2l,t2h,d1,q); +#elif defined(BN_UMULT_HIGH) t2l = d1 * q; t2h = BN_UMULT_HIGH(d1,q); #else |