[llvm-commits] [llvm] r70953 - /llvm/trunk/lib/CodeGen/StackSlotColoring.cpp
Evan Cheng
evan.cheng at apple.com
Mon May 4 17:46:17 PDT 2009
Author: evancheng
Date: Mon May 4 19:46:16 2009
New Revision: 70953
URL: http://llvm.org/viewvc/llvm-project?rev=70953&view=rev
Log:
Do not substitute if the new register isn't in the register class of the operand being updated.
Modified:
llvm/trunk/lib/CodeGen/StackSlotColoring.cpp
Modified: llvm/trunk/lib/CodeGen/StackSlotColoring.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StackSlotColoring.cpp?rev=70953&r1=70952&r2=70953&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/StackSlotColoring.cpp (original)
+++ llvm/trunk/lib/CodeGen/StackSlotColoring.cpp Mon May 4 19:46:16 2009
@@ -477,6 +477,7 @@
bool FoundDef = false; // Not counting 2address def.
bool FoundUse = false;
bool FoundKill = false;
+ const TargetInstrDesc &TID = MII->getDesc();
for (unsigned i = 0, e = MII->getNumOperands(); i != e; ++i) {
MachineOperand &MO = MII->getOperand(i);
if (!MO.isReg())
@@ -485,6 +486,10 @@
if (Reg == 0)
continue;
if (Reg == OldReg) {
+ const TargetRegisterClass *RC = getInstrOperandRegClass(TRI, TID, i);
+ if (RC && !RC->contains(NewReg))
+ return false;
+
if (MO.isUse()) {
FoundUse = true;
if (MO.isKill())
@@ -521,6 +526,7 @@
while (++MII != MBB->end()) {
bool FoundUse = false;
bool FoundKill = false;
+ const TargetInstrDesc &TID = MII->getDesc();
for (unsigned i = 0, e = MII->getNumOperands(); i != e; ++i) {
MachineOperand &MO = MII->getOperand(i);
if (!MO.isReg())
@@ -531,6 +537,10 @@
if (Reg == OldReg) {
if (MO.isDef())
return false;
+
+ const TargetRegisterClass *RC = getInstrOperandRegClass(TRI, TID, i);
+ if (RC && !RC->contains(NewReg))
+ return false;
FoundUse = true;
if (MO.isKill())
FoundKill = true;
@@ -558,6 +568,8 @@
MachineBasicBlock *MBB = MI->getParent();
if (unsigned DstReg = TII->isLoadFromStackSlot(MI, OldFI)) {
if (PropagateForward(MI, MBB, DstReg, Reg)) {
+ DOUT << "Eliminated load: ";
+ DEBUG(MI->dump());
++NumLoadElim;
} else {
TII->copyRegToReg(*MBB, MI, DstReg, Reg, RC, RC);
@@ -565,6 +577,8 @@
}
} else if (unsigned SrcReg = TII->isStoreToStackSlot(MI, OldFI)) {
if (MI->killsRegister(SrcReg) && PropagateBackward(MI, MBB, SrcReg, Reg)) {
+ DOUT << "Eliminated store: ";
+ DEBUG(MI->dump());
++NumStoreElim;
} else {
TII->copyRegToReg(*MBB, MI, Reg, SrcReg, RC, RC);
More information about the llvm-commits
mailing list