constant_propagation_pass: Fold SignExtend{Type}ToLong opcodes if possible
This commit is contained in:
parent
2da2cf9058
commit
43b2eb4688
1 changed files with 14 additions and 0 deletions
|
@ -123,6 +123,15 @@ void FoldSignExtendXToWord(IR::Inst& inst) {
|
|||
inst.ReplaceUsesWith(IR::Value{static_cast<u32>(value)});
|
||||
}
|
||||
|
||||
void FoldSignExtendXToLong(IR::Inst& inst) {
|
||||
if (!inst.AreAllArgsImmediates()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const s64 value = inst.GetArg(0).GetImmediateAsS64();
|
||||
inst.ReplaceUsesWith(IR::Value{static_cast<u64>(value)});
|
||||
}
|
||||
|
||||
void FoldZeroExtendXToWord(IR::Inst& inst) {
|
||||
if (!inst.AreAllArgsImmediates()) {
|
||||
return;
|
||||
|
@ -185,6 +194,11 @@ void ConstantPropagation(IR::Block& block) {
|
|||
case IR::Opcode::SignExtendHalfToWord:
|
||||
FoldSignExtendXToWord(inst);
|
||||
break;
|
||||
case IR::Opcode::SignExtendByteToLong:
|
||||
case IR::Opcode::SignExtendHalfToLong:
|
||||
case IR::Opcode::SignExtendWordToLong:
|
||||
FoldSignExtendXToLong(inst);
|
||||
break;
|
||||
case IR::Opcode::ZeroExtendByteToWord:
|
||||
case IR::Opcode::ZeroExtendHalfToWord:
|
||||
FoldZeroExtendXToWord(inst);
|
||||
|
|
Loading…
Reference in a new issue