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

fix: don't deduplicate binary math of unsigned types #6848

Merged
merged 9 commits into from
Dec 19, 2024
Merged
10 changes: 6 additions & 4 deletions compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,15 +745,17 @@ impl ResultCache {
has_side_effects: bool,
) -> Option<CacheResult> {
self.result.as_ref().and_then(|(origin_block, results)| {
if has_side_effects {
return None
}
asterite marked this conversation as resolved.
Show resolved Hide resolved

if dom.dominates(*origin_block, block) {
Some(CacheResult::Cached(results))
} else if !has_side_effects {
} else {
// Insert a copy of this instruction in the common dominator
let dominator = dom.common_dominator(*origin_block, block);
Some(CacheResult::NeedToHoistToCommonBlock(dominator))
} else {
None
}
}
})
}
}
Expand Down
7 changes: 7 additions & 0 deletions test_programs/execution_success/regression_6834/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "regression_6834"
version = "0.1.0"
type = "bin"
authors = [""]

[dependencies]
2 changes: 2 additions & 0 deletions test_programs/execution_success/regression_6834/Prover.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
year = 2000
min_age = 20
13 changes: 13 additions & 0 deletions test_programs/execution_success/regression_6834/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
fn main(year: u32, min_age: u8) {
if min_age == 0 {
if year > 2028 {
assert((((year - 1) - 2028) / 4 + 1) as i32 >= 0);
}
} else {
if year > 2028 {
// Uncomment the next line and the assertion on line 10 will pass
// assert(year > 2028);
asterite marked this conversation as resolved.
Show resolved Hide resolved
assert((((year - 1) - 2028) / 4 + 1) as i32 >= 0);
}
}
}
Loading