From 067b6212dd8ab715a795e50f09dd26bd1908bba4 Mon Sep 17 00:00:00 2001 From: Tom French Date: Tue, 8 Aug 2023 12:03:19 +0100 Subject: [PATCH] chore: add check that comparison is against zero --- crates/noirc_evaluator/src/ssa/ir/instruction.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/noirc_evaluator/src/ssa/ir/instruction.rs b/crates/noirc_evaluator/src/ssa/ir/instruction.rs index 265a014b8a..204258145c 100644 --- a/crates/noirc_evaluator/src/ssa/ir/instruction.rs +++ b/crates/noirc_evaluator/src/ssa/ir/instruction.rs @@ -594,9 +594,11 @@ impl Binary { return SimplifyResult::SimplifiedTo(zero); } if let Type::Numeric(NumericType::Unsigned { .. }) = operand_type { - // Unsigned values cannot be less than zero. - let zero = dfg.make_constant(FieldElement::zero(), Type::bool()); - return SimplifyResult::SimplifiedTo(zero); + if rhs_is_zero { + // Unsigned values cannot be less than zero. + let zero = dfg.make_constant(FieldElement::zero(), Type::bool()); + return SimplifyResult::SimplifiedTo(zero); + } } } BinaryOp::And => {