From 318662c062f5abfc1fdf5dc2196ca9858a86eca3 Mon Sep 17 00:00:00 2001 From: Tiago Oliveira Date: Wed, 7 Feb 2024 14:12:42 +0100 Subject: [PATCH] mlkem768: replace LEA by add --- .../mlkem/mlkem768/amd64/avx2/kem.jinc | 3 ++- .../mlkem/mlkem768/amd64/ref/kem.jinc | 3 ++- .../mlkem/mlkem768/amd64/ref/poly.jinc | 18 ++++++++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/crypto_kem/mlkem/mlkem768/amd64/avx2/kem.jinc b/src/crypto_kem/mlkem/mlkem768/amd64/avx2/kem.jinc index fabb0c62..1dd5472a 100644 --- a/src/crypto_kem/mlkem/mlkem768/amd64/avx2/kem.jinc +++ b/src/crypto_kem/mlkem/mlkem768/amd64/avx2/kem.jinc @@ -106,7 +106,8 @@ fn __crypto_kem_dec_jazz(reg u64 shkp, reg u64 ctp, reg u64 skp) buf[0:MLKEM_INDCPA_MSGBYTES] = __indcpa_dec_1(buf[0:MLKEM_INDCPA_MSGBYTES], ctp, skp); - hp = #LEA(skp + 32); + //hp = #LEA(skp + 32); + hp = skp; hp += 32; hp += 24 * MLKEM_K * MLKEM_N>>3; /* fixme: should loads be 256-bits long? */ diff --git a/src/crypto_kem/mlkem/mlkem768/amd64/ref/kem.jinc b/src/crypto_kem/mlkem/mlkem768/amd64/ref/kem.jinc index bf93777f..4dab50dc 100644 --- a/src/crypto_kem/mlkem/mlkem768/amd64/ref/kem.jinc +++ b/src/crypto_kem/mlkem/mlkem768/amd64/ref/kem.jinc @@ -107,7 +107,8 @@ fn __crypto_kem_dec_jazz(reg u64 shkp, reg u64 ctp, reg u64 skp) buf[0:MLKEM_MSGBYTES] = __indcpa_dec(buf[0:MLKEM_MSGBYTES], ctp, skp); - hp = #LEA(skp + 32); + //hp = #LEA(skp + 32); + hp = skp; hp += 32; hp += 24 * MLKEM_K * MLKEM_N>>3; for i=0 to MLKEM_SYMBYTES/8 diff --git a/src/crypto_kem/mlkem/mlkem768/amd64/ref/poly.jinc b/src/crypto_kem/mlkem/mlkem768/amd64/ref/poly.jinc index 2f0b7901..62ac2a65 100644 --- a/src/crypto_kem/mlkem/mlkem768/amd64/ref/poly.jinc +++ b/src/crypto_kem/mlkem/mlkem768/amd64/ref/poly.jinc @@ -505,10 +505,12 @@ fn _poly_invntt(reg ptr u16[MLKEM_N] rp) -> reg ptr u16[MLKEM_N] zetasctr += 1; j = start; - cmp = #LEA(start + len); + //cmp = #LEA(start + len); + cmp = start; cmp += len; while (j < cmp) { - offset = #LEA(j + len); + //offset = #LEA(j + len); + offset = j; offset += len; s = rp[(int)offset]; t = rp[(int)j]; m = s; m += t; @@ -519,7 +521,8 @@ fn _poly_invntt(reg ptr u16[MLKEM_N] rp) -> reg ptr u16[MLKEM_N] rp[(int)offset] = t; j += 1; } - start = #LEA(j + len); + //start = #LEA(j + len); + start = j; start += len; } len <<= 1; } @@ -563,10 +566,12 @@ fn _poly_ntt(reg ptr u16[MLKEM_N] rp) -> reg ptr u16[MLKEM_N] zetasctr += 1; zeta = zetasp[(int)zetasctr]; j = start; - cmp = #LEA(start + len); + // cmp = #LEA(start + len); + cmp = start; cmp += len; while (j < cmp) { - offset = #LEA(j + len); + //offset = #LEA(j + len); + offset = j; offset += len; t = rp[(int)offset]; t = __fqmul(t, zeta); s = rp[(int)j]; @@ -577,7 +582,8 @@ fn _poly_ntt(reg ptr u16[MLKEM_N] rp) -> reg ptr u16[MLKEM_N] rp[(int)j] = t; j += 1; } - start = #LEA(j + len); + //start = #LEA(j + len); + start = j; start += len; } len >>= 1; }