Skip to content

Commit

Permalink
mlkem768: replace LEA by add
Browse files Browse the repository at this point in the history
  • Loading branch information
tfaoliveira committed Feb 7, 2024
1 parent 1b2fadc commit 318662c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/crypto_kem/mlkem/mlkem768/amd64/avx2/kem.jinc
Original file line number Diff line number Diff line change
Expand Up @@ -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? */
Expand Down
3 changes: 2 additions & 1 deletion src/crypto_kem/mlkem/mlkem768/amd64/ref/kem.jinc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 12 additions & 6 deletions src/crypto_kem/mlkem/mlkem768/amd64/ref/poly.jinc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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];
Expand All @@ -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;
}
Expand Down

0 comments on commit 318662c

Please sign in to comment.