Skip to content
Merged
Changes from all 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
8 changes: 8 additions & 0 deletions compiler/noirc_evaluator/src/ssa/ir/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,14 @@ impl Instruction {
/// that value is returned. Otherwise None is returned.
fn simplify_cast(value: ValueId, dst_typ: &Type, dfg: &mut DataFlowGraph) -> SimplifyResult {
use SimplifyResult::*;
let value = dfg.resolve(value);

if let Value::Instruction { instruction, .. } = &dfg[value] {
if let Instruction::Cast(original_value, _) = &dfg[*instruction] {
return SimplifiedToInstruction(Instruction::Cast(*original_value, dst_typ.clone()));
}
}

if let Some(constant) = dfg.get_numeric_constant(value) {
let src_typ = dfg.type_of_value(value);
match (src_typ, dst_typ) {
Expand Down