Skip to content

Commit

Permalink
Fix check_unsigned_overflow to not emit range check for mul by bool
Browse files Browse the repository at this point in the history
  • Loading branch information
aakoshh committed Jan 8, 2025
1 parent 6eb09f7 commit 744a872
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion compiler/noirc_evaluator/src/acir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2028,7 +2028,11 @@ impl<'a> Context<'a> {
"attempt to subtract with overflow".to_string()
}
BinaryOp::Mul => {
if bit_size == 1 || max_lhs_bits + max_rhs_bits <= bit_size {
if bit_size == 1
|| max_lhs_bits + max_rhs_bits <= bit_size
|| max_lhs_bits == 1
|| max_rhs_bits == 1
{
// Either performing boolean multiplication (which cannot overflow),
// or `lhs` and `rhs` have both been casted up from smaller types and so cannot overflow.
return Ok(());
Expand Down

0 comments on commit 744a872

Please sign in to comment.