summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorChristopher Lamb <christopher.lamb@gmail.com>2007-08-10 21:11:55 +0000
committerChristopher Lamb <christopher.lamb@gmail.com>2007-08-10 21:11:55 +0000
commite081928f49064b480c2ce1f2bcf97420034fd8d0 (patch)
tree9cc7db1f8fc7d0d4c814c040b4f03af3c1b57e65 /llvm/lib/CodeGen
parentcccc3111103e16e72e1c948dd2d6340ac53d7949 (diff)
downloadbcm5719-llvm-e081928f49064b480c2ce1f2bcf97420034fd8d0.tar.gz
bcm5719-llvm-e081928f49064b480c2ce1f2bcf97420034fd8d0.zip
Move isSubRegOf into MRegisterInfo. Fix a missed move elimination in LowerSubregs and add more debugging output there.
llvm-svn: 41005
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/LowerSubregs.cpp41
1 files changed, 24 insertions, 17 deletions
diff --git a/llvm/lib/CodeGen/LowerSubregs.cpp b/llvm/lib/CodeGen/LowerSubregs.cpp
index 830384427de..dbf7968a744 100644
--- a/llvm/lib/CodeGen/LowerSubregs.cpp
+++ b/llvm/lib/CodeGen/LowerSubregs.cpp
@@ -59,17 +59,6 @@ static const TargetRegisterClass *getPhysicalRegisterRegClass(
return 0;
}
-static bool isSubRegOf(const MRegisterInfo &MRI,
- unsigned SubReg,
- unsigned SupReg) {
- const TargetRegisterDesc &RD = MRI[SubReg];
- for (const unsigned *reg = RD.SuperRegs; *reg != 0; ++reg)
- if (*reg == SupReg)
- return true;
-
- return false;
-}
-
bool LowerSubregsInstructionPass::LowerExtract(MachineInstr *MI) {
MachineBasicBlock *MBB = MI->getParent();
MachineFunction &MF = *MBB->getParent();
@@ -105,7 +94,7 @@ bool LowerSubregsInstructionPass::LowerExtract(MachineInstr *MI) {
}
DOUT << "\n";
- MBB->erase(MI);
+ MBB->remove(MI);
return true;
}
@@ -157,8 +146,8 @@ bool LowerSubregsInstructionPass::LowerInsert(MachineInstr *MI) {
// of the destination, we copy the subreg into the source
// However, this is only safe if the insert instruction is the kill
// of the source register
- bool revCopyOrder = isSubRegOf(MRI, InsReg, DstReg);
- if (revCopyOrder) {
+ bool revCopyOrder = MRI.isSubRegOf(InsReg, DstReg);
+ if (revCopyOrder && InsReg != DstSubReg) {
if (MI->getOperand(1).isKill()) {
DstSubReg = MRI.getSubReg(SrcReg, SubIdx);
// Insert sub-register copy
@@ -168,14 +157,21 @@ bool LowerSubregsInstructionPass::LowerInsert(MachineInstr *MI) {
} else {
TRC1 = MF.getSSARegMap()->getRegClass(InsReg);
}
-
MRI.copyRegToReg(*MBB, MI, DstSubReg, InsReg, TRC1);
+
+#ifndef NDEBUG
MachineBasicBlock::iterator dMI = MI;
DOUT << "subreg: " << *(--dMI);
+#endif
} else {
assert(0 && "Don't know how to convert this insert");
}
}
+#ifndef NDEBUG
+ if (InsReg == DstSubReg) {
+ DOUT << "subreg: Eliminated subreg copy\n";
+ }
+#endif
if (SrcReg != DstReg) {
// Insert super-register copy
@@ -189,9 +185,18 @@ bool LowerSubregsInstructionPass::LowerInsert(MachineInstr *MI) {
"Insert superreg and Dst must be of same register class");
MRI.copyRegToReg(*MBB, MI, DstReg, SrcReg, TRC0);
+
+#ifndef NDEBUG
MachineBasicBlock::iterator dMI = MI;
DOUT << "subreg: " << *(--dMI);
+#endif
+ }
+
+#ifndef NDEBUG
+ if (SrcReg == DstReg) {
+ DOUT << "subreg: Eliminated superreg copy\n";
}
+#endif
if (!revCopyOrder && InsReg != DstSubReg) {
// Insert sub-register copy
@@ -201,14 +206,16 @@ bool LowerSubregsInstructionPass::LowerInsert(MachineInstr *MI) {
} else {
TRC1 = MF.getSSARegMap()->getRegClass(InsReg);
}
-
MRI.copyRegToReg(*MBB, MI, DstSubReg, InsReg, TRC1);
+
+#ifndef NDEBUG
MachineBasicBlock::iterator dMI = MI;
DOUT << "subreg: " << *(--dMI);
+#endif
}
DOUT << "\n";
- MBB->erase(MI);
+ MBB->remove(MI);
return true;
}
OpenPOWER on IntegriCloud