summaryrefslogtreecommitdiff
path: root/integer.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2019-10-18 17:00:17 -0400
committerJeffrey Walton <noloader@gmail.com>2019-10-18 17:00:17 -0400
commit5499cefb8b5421eee16b3b65a90f14ca8151b3fd (patch)
treede6ad34bf691201e1700aec22ffaa4a1f8045f95 /integer.cpp
parent59bfcd5454edb9206c6e781a1e0bbcc3b0a0b138 (diff)
downloadcryptopp-git-5499cefb8b5421eee16b3b65a90f14ca8151b3fd.tar.gz
Use umulh for Aarch64 multiply
This saves about 30% on the Integer multiply operations. For example, RSA 1024 encryption goes from 0.068 to 0.044 ms/op. RSA 2048 goes from 0.170 to 0.100 ms/op. We should have taken this sooner. Ugh...
Diffstat (limited to 'integer.cpp')
-rw-r--r--integer.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/integer.cpp b/integer.cpp
index f5abf83e..a74eb730 100644
--- a/integer.cpp
+++ b/integer.cpp
@@ -200,7 +200,7 @@ static word AtomicInverseModPower2(word A)
// ********************************************************
-#if !defined(CRYPTOPP_NATIVE_DWORD_AVAILABLE) || (defined(__x86_64__) && defined(CRYPTOPP_WORD128_AVAILABLE))
+#if !defined(CRYPTOPP_NATIVE_DWORD_AVAILABLE) || ((defined(__aarch64__) || defined(__x86_64__)) && defined(CRYPTOPP_WORD128_AVAILABLE))
#define TWO_64_BIT_WORDS 1
#define Declare2Words(x) word x##0, x##1;
#define AssignWord(a, b) a##0 = b; a##1 = 0;
@@ -212,6 +212,8 @@ static word AtomicInverseModPower2(word A)
#ifndef __INTEL_COMPILER
#define Double3Words(c, d) d##1 = __shiftleft128(d##0, d##1, 1); d##0 = __shiftleft128(c, d##0, 1); c *= 2;
#endif
+ #elif defined(__aarch32__) || defined(__aarch64__)
+ #define MultiplyWordsLoHi(p0, p1, a, b) p0 = a*b; asm ("umulh %0,%1,%2" : "=r"(p1) : "r"(a), "r"(b));
#elif defined(__DECCXX)
#define MultiplyWordsLoHi(p0, p1, a, b) p0 = a*b; p1 = asm("umulh %a0, %a1, %v0", a, b);
#elif defined(__x86_64__)