Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CT extraction: incorrect with "downto" for loops #858

Closed
cassiersg opened this issue Jul 10, 2024 · 0 comments · Fixed by #859
Closed

CT extraction: incorrect with "downto" for loops #858

cassiersg opened this issue Jul 10, 2024 · 0 comments · Fixed by #859

Comments

@cassiersg
Copy link
Collaborator

Using the following test.jazz file:

export fn test(reg u32 x) -> reg u32 {
    inline int i;
    for i = 1 downto 0 {
        x = x + 1;
    }
    return x;
}

running the extraction as

jasminc -ec test -oec test.ec test.jazz
jasminc -ec test -CT -oec test_ct.ec test.jazz

gives for test.ec:

module M = {
  proc test (x:W32.t) : W32.t = {
    var aux: int;
    
    var i:int;
    
    i <- 1;
    while (0 < i) {
      x <- (x + (W32.of_int 1));
      i <- i - 1;
    }
    return (x);
  }
}.

while for test_ct.ec, the i initialization and bound are incorrect:

module M = {
  var leakages : leakages_t
  
  proc test (x:W32.t) : W32.t = {
    var aux: int;
    var aux_0: W32.t;
    
    var i:int;
    
    leakages <- LeakFor(0,1) :: LeakAddr([]) :: leakages;
    i <- 0;
    while (1 < i) {
      leakages <- LeakAddr([]) :: leakages;
      aux_0 <- (x + (W32.of_int 1));
      x <- aux_0;
      i <- i - 1;
    }
    return (x);
  }
}.
cassiersg added a commit to cassiersg/jasmin that referenced this issue Jul 10, 2024
vbgl pushed a commit that referenced this issue Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant