Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: perform constraints on uncasted values if they are the same type #4303

Merged
merged 3 commits into from
Feb 8, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions compiler/noirc_evaluator/src/ssa/ir/instruction/constrain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,23 @@ pub(super) fn decompose_constrain(
}
}

(
Value::Instruction { instruction: instruction_lhs, .. },
Value::Instruction { instruction: instruction_rhs, .. },
) => {
match (&dfg[*instruction_lhs], &dfg[*instruction_rhs]) {
// Here's we're casting two values just to enforce an equality on them.
jfecher marked this conversation as resolved.
Show resolved Hide resolved
//
// This is equivalent to enforcing equality on the original values.
(Instruction::Cast(original_lhs, _), Instruction::Cast(original_rhs, _))
if dfg.type_of_value(*original_lhs) == dfg.type_of_value(*original_rhs) =>
{
vec![Instruction::Constrain(*original_lhs, *original_rhs, msg.clone())]
}

_ => vec![Instruction::Constrain(lhs, rhs, msg.clone())],
}
}
_ => vec![Instruction::Constrain(lhs, rhs, msg.clone())],
}
}
Expand Down
Loading