diff --git a/src/ir_opt/constant_propagation_pass.cpp b/src/ir_opt/constant_propagation_pass.cpp index 6cab7fc4..037f522e 100644 --- a/src/ir_opt/constant_propagation_pass.cpp +++ b/src/ir_opt/constant_propagation_pass.cpp @@ -122,6 +122,15 @@ void FoldZeroExtendXToWord(IR::Inst& inst) { const u64 value = inst.GetArg(0).GetImmediateAsU64(); inst.ReplaceUsesWith(IR::Value{static_cast(value)}); } + +void FoldZeroExtendXToLong(IR::Inst& inst) { + if (!inst.AreAllArgsImmediates()) { + return; + } + + const u64 value = inst.GetArg(0).GetImmediateAsU64(); + inst.ReplaceUsesWith(IR::Value{value}); +} } // Anonymous namespace void ConstantPropagation(IR::Block& block) { @@ -167,6 +176,11 @@ void ConstantPropagation(IR::Block& block) { case IR::Opcode::ZeroExtendHalfToWord: FoldZeroExtendXToWord(inst); break; + case IR::Opcode::ZeroExtendByteToLong: + case IR::Opcode::ZeroExtendHalfToLong: + case IR::Opcode::ZeroExtendWordToLong: + FoldZeroExtendXToLong(inst); + break; default: break; }