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 0f1af8a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions 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 Expand Up @@ -3674,7 +3678,7 @@ mod test {
return v3
}
";
let ssa = Ssa::from_str(&src).unwrap();
let ssa = Ssa::from_str(src).unwrap();
let brillig = ssa.to_brillig(false);

let (mut acir_functions, _brillig_functions, _, _) = ssa
Expand Down

0 comments on commit 0f1af8a

Please sign in to comment.