diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/IPO/PassManagerBuilder.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopDistribute.cpp | 39 |
2 files changed, 9 insertions, 32 deletions
diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp index 264bc3260b8..724965e27ff 100644 --- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -561,7 +561,7 @@ void PassManagerBuilder::populateModulePassManager( // into separate loop that would otherwise inhibit vectorization. This is // currently only performed for loops marked with the metadata // llvm.loop.distribute=true or when -enable-loop-distribute is specified. - MPM.add(createLoopDistributePass(/*ProcessAllLoopsByDefault=*/false)); + MPM.add(createLoopDistributePass()); MPM.add(createLoopVectorizePass(DisableUnrollLoops, LoopVectorize)); diff --git a/llvm/lib/Transforms/Scalar/LoopDistribute.cpp b/llvm/lib/Transforms/Scalar/LoopDistribute.cpp index 1da0fd8d2a8..b2b2f72aa83 100644 --- a/llvm/lib/Transforms/Scalar/LoopDistribute.cpp +++ b/llvm/lib/Transforms/Scalar/LoopDistribute.cpp @@ -73,11 +73,10 @@ static cl::opt<unsigned> PragmaDistributeSCEVCheckThreshold( "The maximum number of SCEV checks allowed for Loop " "Distribution for loop marked with #pragma loop distribute(enable)")); -// Note that the initial value for this depends on whether the pass is invoked -// directly or from the optimization pipeline. static cl::opt<bool> EnableLoopDistribute( "enable-loop-distribute", cl::Hidden, - cl::desc("Enable the new, experimental LoopDistribution Pass")); + cl::desc("Enable the new, experimental LoopDistribution Pass"), + cl::init(false)); STATISTIC(NumLoopsDistributed, "Number of loops distributed"); @@ -875,8 +874,7 @@ private: /// Shared implementation between new and old PMs. static bool runImpl(Function &F, LoopInfo *LI, DominatorTree *DT, ScalarEvolution *SE, OptimizationRemarkEmitter *ORE, - std::function<const LoopAccessInfo &(Loop &)> &GetLAA, - bool ProcessAllLoops) { + std::function<const LoopAccessInfo &(Loop &)> &GetLAA) { // Build up a worklist of inner-loops to vectorize. This is necessary as the // act of distributing a loop creates new loops and can invalidate iterators // across the loops. @@ -895,7 +893,7 @@ static bool runImpl(Function &F, LoopInfo *LI, DominatorTree *DT, // If distribution was forced for the specific loop to be // enabled/disabled, follow that. Otherwise use the global flag. - if (LDL.isForced().getValueOr(ProcessAllLoops)) + if (LDL.isForced().getValueOr(EnableLoopDistribute)) Changed |= LDL.processLoop(GetLAA); } @@ -906,15 +904,8 @@ static bool runImpl(Function &F, LoopInfo *LI, DominatorTree *DT, /// \brief The pass class. class LoopDistributeLegacy : public FunctionPass { public: - /// \p ProcessAllLoopsByDefault specifies whether loop distribution should be - /// performed by default. Pass -enable-loop-distribute={0,1} overrides this - /// default. We use this to keep LoopDistribution off by default when invoked - /// from the optimization pipeline but on when invoked explicitly from opt. - LoopDistributeLegacy(bool ProcessAllLoopsByDefault = true) - : FunctionPass(ID), ProcessAllLoops(ProcessAllLoopsByDefault) { + LoopDistributeLegacy() : FunctionPass(ID) { // The default is set by the caller. - if (EnableLoopDistribute.getNumOccurrences() > 0) - ProcessAllLoops = EnableLoopDistribute; initializeLoopDistributeLegacyPass(*PassRegistry::getPassRegistry()); } @@ -930,7 +921,7 @@ public: std::function<const LoopAccessInfo &(Loop &)> GetLAA = [&](Loop &L) -> const LoopAccessInfo & { return LAA->getInfo(&L); }; - return runImpl(F, LI, DT, SE, ORE, GetLAA, ProcessAllLoops); + return runImpl(F, LI, DT, SE, ORE, GetLAA); } void getAnalysisUsage(AnalysisUsage &AU) const override { @@ -945,23 +936,11 @@ public: } static char ID; - -private: - /// \brief Whether distribution should be on in this function. The per-loop - /// pragma can override this. - bool ProcessAllLoops; }; } // anonymous namespace PreservedAnalyses LoopDistributePass::run(Function &F, FunctionAnalysisManager &AM) { - // FIXME: This does not currently match the behavior from the old PM. - // ProcessAllLoops with the old PM defaults to true when invoked from opt and - // false when invoked from the optimization pipeline. - bool ProcessAllLoops = false; - if (EnableLoopDistribute.getNumOccurrences() > 0) - ProcessAllLoops = EnableLoopDistribute; - auto &LI = AM.getResult<LoopAnalysis>(F); auto &DT = AM.getResult<DominatorTreeAnalysis>(F); auto &SE = AM.getResult<ScalarEvolutionAnalysis>(F); @@ -973,7 +952,7 @@ PreservedAnalyses LoopDistributePass::run(Function &F, return LAM.getResult<LoopAccessAnalysis>(L); }; - bool Changed = runImpl(F, &LI, &DT, &SE, &ORE, GetLAA, ProcessAllLoops); + bool Changed = runImpl(F, &LI, &DT, &SE, &ORE, GetLAA); if (!Changed) return PreservedAnalyses::all(); PreservedAnalyses PA; @@ -996,7 +975,5 @@ INITIALIZE_PASS_DEPENDENCY(OptimizationRemarkEmitterWrapperPass) INITIALIZE_PASS_END(LoopDistributeLegacy, LDIST_NAME, ldist_name, false, false) namespace llvm { -FunctionPass *createLoopDistributePass(bool ProcessAllLoopsByDefault) { - return new LoopDistributeLegacy(ProcessAllLoopsByDefault); -} +FunctionPass *createLoopDistributePass() { return new LoopDistributeLegacy(); } } |