1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00

Iterative coallescing doesn't buy us anything (we get identical results on

crafty with and without it).  Removing it speeds up live intervals 6%.

llvm-svn: 30010
This commit is contained in:
Chris Lattner 2006-09-01 04:02:42 +00:00
parent ebb3b930fd
commit 0c120af606
2 changed files with 6 additions and 39 deletions

View File

@ -53,17 +53,6 @@ namespace llvm {
std::vector<bool> allocatableRegs_; std::vector<bool> allocatableRegs_;
public: public:
struct CopyRec {
MachineInstr *MI;
unsigned SrcReg, DstReg;
};
CopyRec getCopyRec(MachineInstr *MI, unsigned SrcReg, unsigned DstReg) {
CopyRec R;
R.MI = MI;
R.SrcReg = SrcReg;
R.DstReg = DstReg;
return R;
}
struct InstrSlots { struct InstrSlots {
enum { enum {
LOAD = 0, LOAD = 0,
@ -161,10 +150,8 @@ namespace llvm {
/// joinIntervals - join compatible live intervals /// joinIntervals - join compatible live intervals
void joinIntervals(); void joinIntervals();
/// CopyCoallesceInMBB - Coallsece copies in the specified MBB, putting /// CopyCoallesceInMBB - Coallsece copies in the specified MBB.
/// copies that cannot yet be coallesced into the "TryAgain" list. void CopyCoallesceInMBB(MachineBasicBlock *MBB);
void CopyCoallesceInMBB(MachineBasicBlock *MBB,
std::vector<CopyRec> &TryAgain);
/// JoinCopy - Attempt to join intervals corresponding to SrcReg/DstReg, /// JoinCopy - Attempt to join intervals corresponding to SrcReg/DstReg,
/// which are the src/dst of the copy instruction CopyMI. This returns true /// which are the src/dst of the copy instruction CopyMI. This returns true

View File

@ -1066,8 +1066,7 @@ namespace {
} }
void LiveIntervals::CopyCoallesceInMBB(MachineBasicBlock *MBB, void LiveIntervals::CopyCoallesceInMBB(MachineBasicBlock *MBB) {
std::vector<CopyRec> &TryAgain) {
DEBUG(std::cerr << ((Value*)MBB->getBasicBlock())->getName() << ":\n"); DEBUG(std::cerr << ((Value*)MBB->getBasicBlock())->getName() << ":\n");
for (MachineBasicBlock::iterator MII = MBB->begin(), E = MBB->end(); for (MachineBasicBlock::iterator MII = MBB->begin(), E = MBB->end();
@ -1078,8 +1077,7 @@ void LiveIntervals::CopyCoallesceInMBB(MachineBasicBlock *MBB,
unsigned SrcReg, DstReg; unsigned SrcReg, DstReg;
if (!tii_->isMoveInstr(*Inst, SrcReg, DstReg)) continue; if (!tii_->isMoveInstr(*Inst, SrcReg, DstReg)) continue;
if (!JoinCopy(Inst, SrcReg, DstReg)) JoinCopy(Inst, SrcReg, DstReg);
TryAgain.push_back(getCopyRec(Inst, SrcReg, DstReg));
} }
} }
@ -1087,14 +1085,12 @@ void LiveIntervals::CopyCoallesceInMBB(MachineBasicBlock *MBB,
void LiveIntervals::joinIntervals() { void LiveIntervals::joinIntervals() {
DEBUG(std::cerr << "********** JOINING INTERVALS ***********\n"); DEBUG(std::cerr << "********** JOINING INTERVALS ***********\n");
std::vector<CopyRec> TryAgainList;
const LoopInfo &LI = getAnalysis<LoopInfo>(); const LoopInfo &LI = getAnalysis<LoopInfo>();
if (LI.begin() == LI.end()) { if (LI.begin() == LI.end()) {
// If there are no loops in the function, join intervals in function order. // If there are no loops in the function, join intervals in function order.
for (MachineFunction::iterator I = mf_->begin(), E = mf_->end(); for (MachineFunction::iterator I = mf_->begin(), E = mf_->end();
I != E; ++I) I != E; ++I)
CopyCoallesceInMBB(I, TryAgainList); CopyCoallesceInMBB(I);
} else { } else {
// Otherwise, join intervals in inner loops before other intervals. // Otherwise, join intervals in inner loops before other intervals.
// Unfortunately we can't just iterate over loop hierarchy here because // Unfortunately we can't just iterate over loop hierarchy here because
@ -1109,23 +1105,7 @@ void LiveIntervals::joinIntervals() {
// Finally, join intervals in loop nest order. // Finally, join intervals in loop nest order.
for (unsigned i = 0, e = MBBs.size(); i != e; ++i) for (unsigned i = 0, e = MBBs.size(); i != e; ++i)
CopyCoallesceInMBB(MBBs[i].second, TryAgainList); CopyCoallesceInMBB(MBBs[i].second);
}
// Joining intervals can allow other intervals to be joined. Iteratively join
// until we make no progress.
bool ProgressMade = true;
while (ProgressMade) {
ProgressMade = false;
for (unsigned i = 0, e = TryAgainList.size(); i != e; ++i) {
CopyRec &TheCopy = TryAgainList[i];
if (TheCopy.MI &&
JoinCopy(TheCopy.MI, TheCopy.SrcReg, TheCopy.DstReg)) {
TheCopy.MI = 0; // Mark this one as done.
ProgressMade = true;
}
}
} }
DEBUG(std::cerr << "*** Register mapping ***\n"); DEBUG(std::cerr << "*** Register mapping ***\n");