diff --git a/compiler/noirc_evaluator/src/ssa/ir/instruction.rs b/compiler/noirc_evaluator/src/ssa/ir/instruction.rs index f748aa040a1..badc1e82d50 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/instruction.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/instruction.rs @@ -239,10 +239,19 @@ impl Instruction { pub(crate) fn has_side_effects(&self, dfg: &DataFlowGraph) -> bool { use Instruction::*; - match self { - Binary(_) - | Cast(_, _) + Binary(binary) => { + if matches!(binary.operator, BinaryOp::Div | BinaryOp::Mod) { + if let Some(rhs) = dfg.get_numeric_constant(binary.rhs) { + rhs == FieldElement::zero() + } else { + true + } + } else { + false + } + } + Cast(_, _) | Not(_) | Truncate { .. } | Allocate