|
72 | 72 | #include "llvm/IR/Use.h" |
73 | 73 | #include "llvm/IR/User.h" |
74 | 74 | #include "llvm/IR/Value.h" |
75 | | -#include "llvm/InitializePasses.h" |
76 | | -#include "llvm/Pass.h" |
77 | 75 | #include "llvm/Support/BranchProbability.h" |
78 | 76 | #include "llvm/Support/Casting.h" |
79 | 77 | #include "llvm/Support/CommandLine.h" |
@@ -249,40 +247,8 @@ class InductiveRangeCheckElimination { |
249 | 247 | bool run(Loop *L, function_ref<void(Loop *, bool)> LPMAddNewLoop); |
250 | 248 | }; |
251 | 249 |
|
252 | | -class IRCELegacyPass : public FunctionPass { |
253 | | -public: |
254 | | - static char ID; |
255 | | - |
256 | | - IRCELegacyPass() : FunctionPass(ID) { |
257 | | - initializeIRCELegacyPassPass(*PassRegistry::getPassRegistry()); |
258 | | - } |
259 | | - |
260 | | - void getAnalysisUsage(AnalysisUsage &AU) const override { |
261 | | - AU.addRequired<BranchProbabilityInfoWrapperPass>(); |
262 | | - AU.addRequired<DominatorTreeWrapperPass>(); |
263 | | - AU.addPreserved<DominatorTreeWrapperPass>(); |
264 | | - AU.addRequired<LoopInfoWrapperPass>(); |
265 | | - AU.addPreserved<LoopInfoWrapperPass>(); |
266 | | - AU.addRequired<ScalarEvolutionWrapperPass>(); |
267 | | - AU.addPreserved<ScalarEvolutionWrapperPass>(); |
268 | | - } |
269 | | - |
270 | | - bool runOnFunction(Function &F) override; |
271 | | -}; |
272 | | - |
273 | 250 | } // end anonymous namespace |
274 | 251 |
|
275 | | -char IRCELegacyPass::ID = 0; |
276 | | - |
277 | | -INITIALIZE_PASS_BEGIN(IRCELegacyPass, "irce", |
278 | | - "Inductive range check elimination", false, false) |
279 | | -INITIALIZE_PASS_DEPENDENCY(BranchProbabilityInfoWrapperPass) |
280 | | -INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) |
281 | | -INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass) |
282 | | -INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass) |
283 | | -INITIALIZE_PASS_END(IRCELegacyPass, "irce", "Inductive range check elimination", |
284 | | - false, false) |
285 | | - |
286 | 252 | /// Parse a single ICmp instruction, `ICI`, into a range check. If `ICI` cannot |
287 | 253 | /// be interpreted as a range check, return false and set `Index` and `End` |
288 | 254 | /// to `nullptr`. Otherwise set `Index` to the SCEV being range checked, and |
@@ -1826,39 +1792,6 @@ PreservedAnalyses IRCEPass::run(Function &F, FunctionAnalysisManager &AM) { |
1826 | 1792 | return getLoopPassPreservedAnalyses(); |
1827 | 1793 | } |
1828 | 1794 |
|
1829 | | -bool IRCELegacyPass::runOnFunction(Function &F) { |
1830 | | - if (skipFunction(F)) |
1831 | | - return false; |
1832 | | - |
1833 | | - ScalarEvolution &SE = getAnalysis<ScalarEvolutionWrapperPass>().getSE(); |
1834 | | - BranchProbabilityInfo &BPI = |
1835 | | - getAnalysis<BranchProbabilityInfoWrapperPass>().getBPI(); |
1836 | | - auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree(); |
1837 | | - auto &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo(); |
1838 | | - InductiveRangeCheckElimination IRCE(SE, &BPI, DT, LI); |
1839 | | - |
1840 | | - bool Changed = false; |
1841 | | - |
1842 | | - for (const auto &L : LI) { |
1843 | | - Changed |= simplifyLoop(L, &DT, &LI, &SE, nullptr, nullptr, |
1844 | | - /*PreserveLCSSA=*/false); |
1845 | | - Changed |= formLCSSARecursively(*L, DT, &LI, &SE); |
1846 | | - } |
1847 | | - |
1848 | | - SmallPriorityWorklist<Loop *, 4> Worklist; |
1849 | | - appendLoopsToWorklist(LI, Worklist); |
1850 | | - auto LPMAddNewLoop = [&](Loop *NL, bool IsSubloop) { |
1851 | | - if (!IsSubloop) |
1852 | | - appendLoopsToWorklist(*NL, Worklist); |
1853 | | - }; |
1854 | | - |
1855 | | - while (!Worklist.empty()) { |
1856 | | - Loop *L = Worklist.pop_back_val(); |
1857 | | - Changed |= IRCE.run(L, LPMAddNewLoop); |
1858 | | - } |
1859 | | - return Changed; |
1860 | | -} |
1861 | | - |
1862 | 1795 | bool |
1863 | 1796 | InductiveRangeCheckElimination::isProfitableToTransform(const Loop &L, |
1864 | 1797 | LoopStructure &LS) { |
@@ -1998,7 +1931,3 @@ bool InductiveRangeCheckElimination::run( |
1998 | 1931 |
|
1999 | 1932 | return Changed; |
2000 | 1933 | } |
2001 | | - |
2002 | | -Pass *llvm::createInductiveRangeCheckEliminationPass() { |
2003 | | - return new IRCELegacyPass(); |
2004 | | -} |
0 commit comments