Skip to content

Commit

Permalink
account for has_side_effects in ResultCache get
Browse files Browse the repository at this point in the history
  • Loading branch information
vezenovm committed Dec 17, 2024
1 parent 55153df commit 0be4c79
Showing 1 changed file with 6 additions and 4 deletions.
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
}

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

0 comments on commit 0be4c79

Please sign in to comment.