constant_propagation_pass: Fold SignExtend{Type}ToWord opcodes if possible
This commit is contained in:
parent
c42f6ea184
commit
2da2cf9058
1 changed files with 13 additions and 0 deletions
|
@ -114,6 +114,15 @@ void FoldOR(IR::Inst& inst, bool is_32_bit) {
|
|||
}
|
||||
}
|
||||
|
||||
void FoldSignExtendXToWord(IR::Inst& inst) {
|
||||
if (!inst.AreAllArgsImmediates()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const s64 value = inst.GetArg(0).GetImmediateAsS64();
|
||||
inst.ReplaceUsesWith(IR::Value{static_cast<u32>(value)});
|
||||
}
|
||||
|
||||
void FoldZeroExtendXToWord(IR::Inst& inst) {
|
||||
if (!inst.AreAllArgsImmediates()) {
|
||||
return;
|
||||
|
@ -172,6 +181,10 @@ void ConstantPropagation(IR::Block& block) {
|
|||
case IR::Opcode::Not64:
|
||||
FoldNOT(inst, opcode == IR::Opcode::Not32);
|
||||
break;
|
||||
case IR::Opcode::SignExtendByteToWord:
|
||||
case IR::Opcode::SignExtendHalfToWord:
|
||||
FoldSignExtendXToWord(inst);
|
||||
break;
|
||||
case IR::Opcode::ZeroExtendByteToWord:
|
||||
case IR::Opcode::ZeroExtendHalfToWord:
|
||||
FoldZeroExtendXToWord(inst);
|
||||
|
|
Loading…
Reference in a new issue