From ee1a9f3b4e168b375b462b8ee6445696ee0eba4c Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Wed, 3 Apr 2024 16:10:04 +0100 Subject: [PATCH] fix(ssa): Do not use get_value_max_num_bits when we want pure type information (#4700) # Description ## Problem\* No issue as this was found by @jfecher while testing in debug mode where we get overflow errors after https://github.com/noir-lang/noir/pull/4691 Resolves https://github.com/noir-lang/noir/pull/4699#discussion_r1548634192 ## Summary\* ## Additional Context ## Documentation\* Check one: - [ ] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [ ] I have tested the changes locally. - [ ] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --------- Co-authored-by: Tom French --- .../src/ssa/ir/instruction/binary.rs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/compiler/noirc_evaluator/src/ssa/ir/instruction/binary.rs b/compiler/noirc_evaluator/src/ssa/ir/instruction/binary.rs index e491807995b..9099268ace9 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/instruction/binary.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/instruction/binary.rs @@ -171,21 +171,6 @@ impl Binary { return SimplifyResult::SimplifiedTo(one); } - if operand_type.is_unsigned() { - // If we're comparing a variable against a constant value which lies outside of the range of - // values which the variable's type can take, we can assume that the equality will be false. - let constant = lhs.or(rhs); - let non_constant = if lhs.is_some() { self.rhs } else { self.lhs }; - if let Some(constant) = constant { - let max_possible_value = - 2u128.pow(dfg.get_value_max_num_bits(non_constant)) - 1; - if constant > max_possible_value.into() { - let zero = dfg.make_constant(FieldElement::zero(), Type::bool()); - return SimplifyResult::SimplifiedTo(zero); - } - } - } - if operand_type == Type::bool() { // Simplify forms of `(boolean == true)` into `boolean` if lhs_is_one {