Skip to content

Commit

Permalink
fix: remove unnecessary cast in bit-shift (#6890)
Browse files Browse the repository at this point in the history
  • Loading branch information
guipublic authored Dec 23, 2024
1 parent 03b58fa commit 011fbc1
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions compiler/noirc_evaluator/src/ssa/opt/remove_bit_shifts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ impl Context<'_> {
let bit_size_var = self.numeric_constant(FieldElement::from(bit_size as u128), u8_type);
let overflow = self.insert_binary(rhs, BinaryOp::Lt, bit_size_var);
let predicate = self.insert_cast(overflow, typ);
// we can safely cast to unsigned because overflow_checks prevent bit-shift with a negative value
let rhs_unsigned = self.insert_cast(rhs, NumericType::unsigned(bit_size));
let pow = self.pow(base, rhs_unsigned);
let pow = self.pow(base, rhs);
let pow = self.insert_cast(pow, typ);
(FieldElement::max_num_bits(), self.insert_binary(predicate, BinaryOp::Mul, pow))
};
Expand Down

0 comments on commit 011fbc1

Please sign in to comment.