[llvm-commits] [llvm] r160027 - /llvm/trunk/lib/CodeGen/EarlyIfConversion.cpp
Jakob Stoklund Olesen
stoklund at 2pi.dk
Tue Jul 10 15:39:56 PDT 2012
Author: stoklund
Date: Tue Jul 10 17:39:56 2012
New Revision: 160027
URL: http://llvm.org/viewvc/llvm-project?rev=160027&view=rev
Log:
Require and preserve LoopInfo for early if-conversion.
It will surely be needed by heuristics.
Modified:
llvm/trunk/lib/CodeGen/EarlyIfConversion.cpp
Modified: llvm/trunk/lib/CodeGen/EarlyIfConversion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/EarlyIfConversion.cpp?rev=160027&r1=160026&r2=160027&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/EarlyIfConversion.cpp (original)
+++ llvm/trunk/lib/CodeGen/EarlyIfConversion.cpp Tue Jul 10 17:39:56 2012
@@ -27,6 +27,7 @@
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
+#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/Target/TargetInstrInfo.h"
@@ -513,6 +514,7 @@
const TargetRegisterInfo *TRI;
MachineRegisterInfo *MRI;
MachineDominatorTree *DomTree;
+ MachineLoopInfo *Loops;
SSAIfConv IfConv;
public:
@@ -524,6 +526,7 @@
private:
bool tryConvertIf(MachineBasicBlock*);
void updateDomTree(ArrayRef<MachineBasicBlock*> Removed);
+ void updateLoops(ArrayRef<MachineBasicBlock*> Removed);
};
} // end anonymous namespace
@@ -541,6 +544,8 @@
AU.addRequired<MachineBranchProbabilityInfo>();
AU.addRequired<MachineDominatorTree>();
AU.addPreserved<MachineDominatorTree>();
+ AU.addRequired<MachineLoopInfo>();
+ AU.addPreserved<MachineLoopInfo>();
MachineFunctionPass::getAnalysisUsage(AU);
}
@@ -561,6 +566,16 @@
}
}
+/// Update LoopInfo after if-conversion.
+void EarlyIfConverter::updateLoops(ArrayRef<MachineBasicBlock*> Removed) {
+ if (!Loops)
+ return;
+ // If-conversion doesn't change loop structure, and it doesn't mess with back
+ // edges, so updating LoopInfo is simply removing the dead blocks.
+ for (unsigned i = 0, e = Removed.size(); i != e; ++i)
+ Loops->removeBlock(Removed[i]);
+}
+
/// Attempt repeated if-conversion on MBB, return true if successful.
///
bool EarlyIfConverter::tryConvertIf(MachineBasicBlock *MBB) {
@@ -571,6 +586,7 @@
IfConv.convertIf(RemovedBlocks);
Changed = true;
updateDomTree(RemovedBlocks);
+ updateLoops(RemovedBlocks);
}
return Changed;
}
@@ -583,6 +599,7 @@
TRI = MF.getTarget().getRegisterInfo();
MRI = &MF.getRegInfo();
DomTree = &getAnalysis<MachineDominatorTree>();
+ Loops = getAnalysisIfAvailable<MachineLoopInfo>();
bool Changed = false;
IfConv.runOnMachineFunction(MF);
More information about the llvm-commits
mailing list