Skip to content

Commit

Permalink
Merge 1e82b87 into 24f6d85
Browse files Browse the repository at this point in the history
  • Loading branch information
vezenovm authored Apr 3, 2024
2 parents 24f6d85 + 1e82b87 commit 4e8dfa5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions compiler/noirc_evaluator/src/ssa/ir/dfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,16 @@ impl DataFlowGraph {
pub(crate) fn get_value_max_num_bits(&self, value: ValueId) -> u32 {
match self[value] {
Value::Instruction { instruction, .. } => {
let bit_size = self.type_of_value(value).bit_size();
if let Instruction::Cast(original_value, _) = self[instruction] {
self.type_of_value(original_value).bit_size()
let original_bit_size = self.type_of_value(original_value).bit_size();
if original_bit_size < bit_size {
original_bit_size
} else {
bit_size
}
} else {
self.type_of_value(value).bit_size()
bit_size
}
}

Expand Down
2 changes: 2 additions & 0 deletions compiler/noirc_evaluator/src/ssa/ir/instruction/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ impl Binary {
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.
// When checking the variable's max range we want to make sure to include type information
// from previous casts which tell us whether the variable was cast up from a smaller type.
let constant = lhs.or(rhs);
let non_constant = if lhs.is_some() { self.rhs } else { self.lhs };
if let Some(constant) = constant {
Expand Down

0 comments on commit 4e8dfa5

Please sign in to comment.