| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent eeab210 commit 9f468cc
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -110,12 +110,34 @@ static ossl_inline void _mul_limb(limb_t *hi, limb_t *lo, limb_t a, limb_t b) | |||
| 110 | 110 | *lo = (limb_t)t; | |
| 111 | 111 | } | |
| 112 | 112 | #elif (BN_BYTES == 8) && (defined _MSC_VER) | |
| 113 | - /* https://learn.microsoft.com/en-us/cpp/intrinsics/umul128?view=msvc-170 */ | ||
| 113 | + # if defined(_M_X64) | ||
| 114 | + /* | ||
| 115 | + * on x86_64 (x64) we can use the _umul128 intrinsic to get one `mul` | ||
| 116 | + * instruction to get both high and low 64 bits of the multiplication. | ||
| 117 | + * https://learn.microsoft.com/en-us/cpp/intrinsics/umul128?view=msvc-140 | ||
| 118 | + */ | ||
| 119 | + #include <intrin.h> | ||
| 114 | 120 | #pragma intrinsic(_umul128) | |
| 115 | 121 | static ossl_inline void _mul_limb(limb_t *hi, limb_t *lo, limb_t a, limb_t b) | |
| 116 | 122 | { | |
| 117 | 123 | *lo = _umul128(a, b, hi); | |
| 118 | 124 | } | |
| 125 | + # elif defined(_M_ARM64) || defined (_M_IA64) | ||
| 126 | + /* | ||
| 127 | + * We can't use the __umulh() on x86_64 as then msvc generates two `mul` | ||
| 128 | + * instructions; so use this more portable intrinsic on platforms that | ||
| 129 | + * don't support _umul128 (like aarch64 (ARM64) or ia64) | ||
| 130 | + * https://learn.microsoft.com/en-us/cpp/intrinsics/umulh?view=msvc-140 | ||
| 131 | + */ | ||
| 132 | + #include <intrin.h> | ||
| 133 | + static ossl_inline void _mul_limb(limb_t *hi, limb_t *lo, limb_t a, limb_t b) | ||
| 134 | + { | ||
| 135 | + *lo = a * b; | ||
| 136 | + *hi = __umulh(a, b); | ||
| 137 | + } | ||
| 138 | + # else | ||
| 139 | + # error Only x64, ARM64 and IA64 supported. | ||
| 140 | + # endif /* defined(_M_X64) */ | ||
| 119 | 141 | #else | |
| 120 | 142 | /* | |
| 121 | 143 | * if the compiler doesn't have either a 128bit data type nor a "return | |
| Back | FazBrowse Home | New Git URL |
0 commit comments