Skip to content

Commit

Permalink
feat: Optimize x < 0 for unsigned x to false
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed Aug 8, 2023
1 parent a72cc96 commit bae2e53
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions crates/noirc_evaluator/src/ssa/ir/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,13 @@ impl Binary {
let zero = dfg.make_constant(FieldElement::zero(), Type::bool());
return SimplifyResult::SimplifiedTo(zero);
}
if let Type::Numeric(NumericType::Unsigned { .. }) = operand_type {
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 => {
if lhs_is_zero || rhs_is_zero {
Expand Down

0 comments on commit bae2e53

Please sign in to comment.