From bce134745a536682e0e56fe3c31a5aba6d9afb78 Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Tue, 24 Sep 2024 09:24:09 +0000 Subject: [PATCH] . --- compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs b/compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs index d14f50891ea..7d85840b99a 100644 --- a/compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs +++ b/compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs @@ -615,7 +615,8 @@ impl<'f> PerFunctionContext<'f> { fn reduce_load_result_count(&mut self, value: ValueId) { if let Some(context) = self.load_results.get_mut(&value) { - context.uses = context.uses.saturating_sub(1); + // TODO this was saturating https://github.com/noir-lang/noir/issues/6124 + context.uses = context.uses.wrapping_sub(1); } } @@ -743,7 +744,8 @@ impl<'f> PerFunctionContext<'f> { if all_loads_removed && !store_alias_used { self.instructions_to_remove.insert(*store_instruction); if let Some((_, counter)) = remaining_last_stores.get_mut(store_address) { - *counter = counter.saturating_sub(1); + // TODO this was saturating https://github.com/noir-lang/noir/issues/6124 + *counter = counter.wrapping_sub(1); } } else if let Some((_, counter)) = remaining_last_stores.get_mut(store_address) { *counter += 1;