Skip to content

Commit

Permalink
Tighter loop bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
vbgl committed Feb 17, 2024
1 parent e6a20d7 commit 82d5ba7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion code/jasmin/mlkem_avx2/extraction/jkem_avx2.ec
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ module M(SC:Syscall_t) = {
e <- s_e;
c <- (W64.of_int 0);

while ((c \ult (W64.of_int 24))) {
while ((c \ult (W64.of_int (24 - 1)))) {
rc <- rC.[(W64.to_uint c)];
e <@ keccakf1600_round (e, a, rc);
rc <- rC.[((W64.to_uint c) + 1)];
Expand Down
2 changes: 1 addition & 1 deletion code/jasmin/mlkem_avx2/keccakf1600.jinc
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ inline fn __keccakf1600(reg ptr u64[25] a) -> reg ptr u64[25]
e = s_e;

c = 0;
while (c < KECCAK_ROUNDS)
while (c < KECCAK_ROUNDS - 1)
{
rc = RC[(int) c];
e = keccakf1600_round(e, a, rc);
Expand Down
8 changes: 4 additions & 4 deletions code/jasmin/mlkem_ref/extraction/jkem.ec
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ module M(SC:Syscall_t) = {
e <- s_e;
c <- (W64.of_int 0);

while ((c \ult (W64.of_int 24))) {
while ((c \ult (W64.of_int (24 - 1)))) {
rc <- rC.[(W64.to_uint c)];
e <@ keccakf1600_round (e, a, rc);
rc <- rC.[((W64.to_uint c) + 1)];
Expand Down Expand Up @@ -1351,7 +1351,7 @@ module M(SC:Syscall_t) = {
j <- (W64.of_int 0);
aa <@ __polyvec_csubq (a);

while ((i \ult (W64.of_int (3 * 256)))) {
while ((i \ult (W64.of_int ((3 * 256) - 3)))) {
k <- 0;
while (k < 4) {
t.[k] <- (zeroextu64 aa.[(W64.to_uint i)]);
Expand Down Expand Up @@ -1413,7 +1413,7 @@ module M(SC:Syscall_t) = {
j <- (W64.of_int 0);
aa <@ __polyvec_csubq (a);

while ((i \ult (W64.of_int (3 * 256)))) {
while ((i \ult (W64.of_int ((3 * 256) - 3)))) {
k <- 0;
while (k < 4) {
t.[k] <- (zeroextu64 aa.[(W64.to_uint i)]);
Expand Down Expand Up @@ -1471,7 +1471,7 @@ module M(SC:Syscall_t) = {
i <- (W64.of_int 0);
j <- (W64.of_int 0);

while ((i \ult (W64.of_int (3 * 256)))) {
while ((i \ult (W64.of_int ((3 * 256) - 3)))) {
k <- 0;
while (k < 5) {
t.[k] <- (zeroextu32 (loadW8 Glob.mem (W64.to_uint (ap + j))));
Expand Down
2 changes: 1 addition & 1 deletion code/jasmin/mlkem_ref/fips202.jinc
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ inline fn __keccakf1600(reg ptr u64[25] a) -> reg ptr u64[25]
e = s_e;

c = 0;
while (c < KECCAK_ROUNDS)
while (c < KECCAK_ROUNDS - 1)
{
rc = RC[(int) c];
e = keccakf1600_round(e, a, rc);
Expand Down
6 changes: 3 additions & 3 deletions code/jasmin/mlkem_ref/polyvec.jinc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn __polyvec_compress(reg u64 rp, stack u16[MLKEM_VECN] a)

aa = __polyvec_csubq(a);

while (i < MLKEM_VECN)
while (i < MLKEM_VECN - 3)
{
for k = 0 to 4
{
Expand Down Expand Up @@ -98,7 +98,7 @@ fn __i_polyvec_compress(reg ptr u8[MLKEM_POLYVECCOMPRESSEDBYTES] rp, stack u16[M

aa = __polyvec_csubq(a);

while (i < MLKEM_VECN)
while (i < MLKEM_VECN - 3)
{
for k = 0 to 4
{
Expand Down Expand Up @@ -161,7 +161,7 @@ fn __polyvec_decompress(reg u64 ap) -> stack u16[MLKEM_VECN]
i = 0;
j = 0;

while (i < MLKEM_VECN)
while (i < MLKEM_VECN - 3)
{
for k = 0 to 5
{
Expand Down

0 comments on commit 82d5ba7

Please sign in to comment.