From 0be4c7994d423534fb0d724cf6213bd1ff3a104e Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Tue, 17 Dec 2024 20:26:06 +0000 Subject: [PATCH] account for has_side_effects in ResultCache get --- .../noirc_evaluator/src/ssa/opt/constant_folding.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs b/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs index c81a557178b..62204ed93bd 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs @@ -745,15 +745,17 @@ impl ResultCache { has_side_effects: bool, ) -> Option { 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 - } + } }) } }