diff --git a/k12_and_key_utils.h b/k12_and_key_utils.h index 1637911..9d7b198 100644 --- a/k12_and_key_utils.h +++ b/k12_and_key_utils.h @@ -1277,6 +1277,13 @@ static void table_lookup_fixed_base(point_precomp_t P, unsigned int digit, unsig } } +// MSVC (VC2022 17.14 specifically) does not strictly preserve left-to-right evaluation order. +// So turn off the optimization for 2 functions +// - multiply +// - Montgomery_multiply_mod_order +#ifdef _MSC_VER +#pragma optimize( "", off ) +#endif static void multiply(const unsigned long long* a, const unsigned long long* b, unsigned long long* c) { unsigned long long u, v, uv; @@ -1343,6 +1350,10 @@ static void Montgomery_multiply_mod_order(const unsigned long long* ma, const un } } +#ifdef _MSC_VER +#pragma optimize( "", on ) +#endif + static void eccnorm(point_extproj_t P, point_t Q) { // Normalize a projective point (X1:Y1:Z1), including full reduction