Skip to content

Commit

Permalink
Add a test that fails
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite committed Nov 26, 2024
1 parent 42b9dac commit 2d19468
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1341,4 +1341,26 @@ mod test {
let ssa = ssa.fold_constants_with_brillig(&brillig);
assert_normalized_ssa_equals(ssa, expected);
}

#[test]
fn does_not_use_cached_constrain_in_block_that_is_not_dominated() {
let src = "
brillig(inline) fn main f0 {
b0(v0: Field, v1: Field):
v3 = eq v0, Field 0
jmpif v3 then: b1, else: b2
b1():
v5 = eq v1, Field 1
constrain v1 == Field 1
jmp b2()
b2():
v6 = eq v1, Field 0
constrain v1 == Field 0
return
}
";
let ssa = Ssa::from_str(src).unwrap();
let ssa = ssa.fold_constants_using_constraints();
assert_normalized_ssa_equals(ssa, src);
}
}

0 comments on commit 2d19468

Please sign in to comment.