mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-14 14:24:05 +00:00
Do not substitute if the new register isn't in the register class of the operand being updated.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70953 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -477,6 +477,7 @@ bool StackSlotColoring::PropagateBackward(MachineBasicBlock::iterator MII,
|
|||||||
bool FoundDef = false; // Not counting 2address def.
|
bool FoundDef = false; // Not counting 2address def.
|
||||||
bool FoundUse = false;
|
bool FoundUse = false;
|
||||||
bool FoundKill = false;
|
bool FoundKill = false;
|
||||||
|
const TargetInstrDesc &TID = MII->getDesc();
|
||||||
for (unsigned i = 0, e = MII->getNumOperands(); i != e; ++i) {
|
for (unsigned i = 0, e = MII->getNumOperands(); i != e; ++i) {
|
||||||
MachineOperand &MO = MII->getOperand(i);
|
MachineOperand &MO = MII->getOperand(i);
|
||||||
if (!MO.isReg())
|
if (!MO.isReg())
|
||||||
@ -485,6 +486,10 @@ bool StackSlotColoring::PropagateBackward(MachineBasicBlock::iterator MII,
|
|||||||
if (Reg == 0)
|
if (Reg == 0)
|
||||||
continue;
|
continue;
|
||||||
if (Reg == OldReg) {
|
if (Reg == OldReg) {
|
||||||
|
const TargetRegisterClass *RC = getInstrOperandRegClass(TRI, TID, i);
|
||||||
|
if (RC && !RC->contains(NewReg))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (MO.isUse()) {
|
if (MO.isUse()) {
|
||||||
FoundUse = true;
|
FoundUse = true;
|
||||||
if (MO.isKill())
|
if (MO.isKill())
|
||||||
@ -521,6 +526,7 @@ bool StackSlotColoring::PropagateForward(MachineBasicBlock::iterator MII,
|
|||||||
while (++MII != MBB->end()) {
|
while (++MII != MBB->end()) {
|
||||||
bool FoundUse = false;
|
bool FoundUse = false;
|
||||||
bool FoundKill = false;
|
bool FoundKill = false;
|
||||||
|
const TargetInstrDesc &TID = MII->getDesc();
|
||||||
for (unsigned i = 0, e = MII->getNumOperands(); i != e; ++i) {
|
for (unsigned i = 0, e = MII->getNumOperands(); i != e; ++i) {
|
||||||
MachineOperand &MO = MII->getOperand(i);
|
MachineOperand &MO = MII->getOperand(i);
|
||||||
if (!MO.isReg())
|
if (!MO.isReg())
|
||||||
@ -531,6 +537,10 @@ bool StackSlotColoring::PropagateForward(MachineBasicBlock::iterator MII,
|
|||||||
if (Reg == OldReg) {
|
if (Reg == OldReg) {
|
||||||
if (MO.isDef())
|
if (MO.isDef())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
const TargetRegisterClass *RC = getInstrOperandRegClass(TRI, TID, i);
|
||||||
|
if (RC && !RC->contains(NewReg))
|
||||||
|
return false;
|
||||||
FoundUse = true;
|
FoundUse = true;
|
||||||
if (MO.isKill())
|
if (MO.isKill())
|
||||||
FoundKill = true;
|
FoundKill = true;
|
||||||
@ -558,6 +568,8 @@ void StackSlotColoring::UnfoldAndRewriteInstruction(MachineInstr *MI, int OldFI,
|
|||||||
MachineBasicBlock *MBB = MI->getParent();
|
MachineBasicBlock *MBB = MI->getParent();
|
||||||
if (unsigned DstReg = TII->isLoadFromStackSlot(MI, OldFI)) {
|
if (unsigned DstReg = TII->isLoadFromStackSlot(MI, OldFI)) {
|
||||||
if (PropagateForward(MI, MBB, DstReg, Reg)) {
|
if (PropagateForward(MI, MBB, DstReg, Reg)) {
|
||||||
|
DOUT << "Eliminated load: ";
|
||||||
|
DEBUG(MI->dump());
|
||||||
++NumLoadElim;
|
++NumLoadElim;
|
||||||
} else {
|
} else {
|
||||||
TII->copyRegToReg(*MBB, MI, DstReg, Reg, RC, RC);
|
TII->copyRegToReg(*MBB, MI, DstReg, Reg, RC, RC);
|
||||||
@ -565,6 +577,8 @@ void StackSlotColoring::UnfoldAndRewriteInstruction(MachineInstr *MI, int OldFI,
|
|||||||
}
|
}
|
||||||
} else if (unsigned SrcReg = TII->isStoreToStackSlot(MI, OldFI)) {
|
} else if (unsigned SrcReg = TII->isStoreToStackSlot(MI, OldFI)) {
|
||||||
if (MI->killsRegister(SrcReg) && PropagateBackward(MI, MBB, SrcReg, Reg)) {
|
if (MI->killsRegister(SrcReg) && PropagateBackward(MI, MBB, SrcReg, Reg)) {
|
||||||
|
DOUT << "Eliminated store: ";
|
||||||
|
DEBUG(MI->dump());
|
||||||
++NumStoreElim;
|
++NumStoreElim;
|
||||||
} else {
|
} else {
|
||||||
TII->copyRegToReg(*MBB, MI, Reg, SrcReg, RC, RC);
|
TII->copyRegToReg(*MBB, MI, Reg, SrcReg, RC, RC);
|
||||||
|
Reference in New Issue
Block a user