Skip to content

Commit 14ce54e

Browse files
authored
Turn off optimization for MSVC in mutiply and Montgomery_multiply_mod_order. (#110)
1 parent 81a4c2f commit 14ce54e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

k12_and_key_utils.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,13 @@ static void table_lookup_fixed_base(point_precomp_t P, unsigned int digit, unsig
12771277
}
12781278
}
12791279

1280+
// MSVC (VC2022 17.14 specifically) does not strictly preserve left-to-right evaluation order.
1281+
// So turn off the optimization for 2 functions
1282+
// - multiply
1283+
// - Montgomery_multiply_mod_order
1284+
#ifdef _MSC_VER
1285+
#pragma optimize( "", off )
1286+
#endif
12801287
static void multiply(const unsigned long long* a, const unsigned long long* b, unsigned long long* c)
12811288
{
12821289
unsigned long long u, v, uv;
@@ -1343,6 +1350,10 @@ static void Montgomery_multiply_mod_order(const unsigned long long* ma, const un
13431350
}
13441351
}
13451352

1353+
#ifdef _MSC_VER
1354+
#pragma optimize( "", on )
1355+
#endif
1356+
13461357
static void eccnorm(point_extproj_t P, point_t Q)
13471358
{ // Normalize a projective point (X1:Y1:Z1), including full reduction
13481359

0 commit comments

Comments
 (0)