Skip to content

Commit

Permalink
Merge 59b88a6 into 656665e
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench authored Apr 2, 2024
2 parents 656665e + 59b88a6 commit c36a638
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
10 changes: 5 additions & 5 deletions compiler/noirc_evaluator/src/ssa/ir/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,12 +573,12 @@ impl Instruction {
Instruction::IncrementRc { .. } => None,
Instruction::DecrementRc { .. } => None,
Instruction::RangeCheck { value, max_bit_size, .. } => {
if let Some(numeric_constant) = dfg.get_numeric_constant(*value) {
if numeric_constant.num_bits() < *max_bit_size {
return Remove;
}
let max_potential_bits = dfg.get_value_max_num_bits(*value);
if max_potential_bits < *max_bit_size {
Remove
} else {
None
}
None
}
}
}
Expand Down
15 changes: 10 additions & 5 deletions compiler/noirc_evaluator/src/ssa/ir/instruction/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,16 @@ pub(super) fn simplify_call(
let max_bit_size = dfg.get_numeric_constant(arguments[1]);
if let Some(max_bit_size) = max_bit_size {
let max_bit_size = max_bit_size.to_u128() as u32;
SimplifyResult::SimplifiedToInstruction(Instruction::RangeCheck {
value,
max_bit_size,
assert_message: Some("call to assert_max_bit_size".to_owned()),
})
let max_potential_bits = dfg.get_value_max_num_bits(value);
if max_potential_bits < max_bit_size {
SimplifyResult::Remove
} else {
SimplifyResult::SimplifiedToInstruction(Instruction::RangeCheck {
value,
max_bit_size,
assert_message: Some("call to assert_max_bit_size".to_owned()),
})
}
} else {
SimplifyResult::None
}
Expand Down

0 comments on commit c36a638

Please sign in to comment.