constant_propagation_pass: Fold ZeroExtend{Type}ToLong opcodes if possible
These are equivalent to the ZeroExtendXToWord variants, so we can trivially do this as well.
This commit is contained in:
parent
2274214ff0
commit
c42f6ea184
1 changed files with 14 additions and 0 deletions
|
@ -122,6 +122,15 @@ void FoldZeroExtendXToWord(IR::Inst& inst) {
|
|||
const u64 value = inst.GetArg(0).GetImmediateAsU64();
|
||||
inst.ReplaceUsesWith(IR::Value{static_cast<u32>(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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue