Index: polly/trunk/include/polly/Support/ScopHelper.h =================================================================== --- polly/trunk/include/polly/Support/ScopHelper.h +++ polly/trunk/include/polly/Support/ScopHelper.h @@ -435,5 +435,24 @@ std::tuple, std::vector> getIndexExpressionsFromGEP(llvm::GetElementPtrInst *GEP, llvm::ScalarEvolution &SE); + +// If the loop is nonaffine/boxed, return the first non-boxed surrounding loop +// for Polly. If the loop is affine, return the loop itself. +// +// @param L Pointer to the Loop object to analyze. +// @param LI Reference to the LoopInfo. +// @param Boxed Loops Set of Boxed Loops we get from the SCoP. +llvm::Loop *getFirstNonBoxedLoopFor(llvm::Loop *L, llvm::LoopInfo &LI, + const BoxedLoopsSetTy &BoxedLoops); + +// If the Basic Block belongs to a loop that is nonaffine/boxed, return the +// first non-boxed surrounding loop for Polly. If the loop is affine, return +// the loop itself. +// +// @param BB Pointer to the Basic Block to analyze. +// @param LI Reference to the LoopInfo. +// @param Boxed Loops Set of Boxed Loops we get from the SCoP. +llvm::Loop *getFirstNonBoxedLoopFor(llvm::BasicBlock *BB, llvm::LoopInfo &LI, + const BoxedLoopsSetTy &BoxedLoops); } // namespace polly #endif Index: polly/trunk/lib/Analysis/ScopBuilder.cpp =================================================================== --- polly/trunk/lib/Analysis/ScopBuilder.cpp +++ polly/trunk/lib/Analysis/ScopBuilder.cpp @@ -31,17 +31,6 @@ STATISTIC(InfeasibleScops, "Number of SCoPs with statically infeasible context."); -// If the loop is nonaffine/boxed, return the first non-boxed surrounding loop -// for Polly. If the loop is affine, return the loop itself. Do not call -// `getSCEVAtScope()` on the result of `getFirstNonBoxedLoopFor()`, as we need -// to analyze the memory accesses of the nonaffine/boxed loops. -static Loop *getFirstNonBoxedLoopFor(Loop *L, LoopInfo &LI, - const BoxedLoopsSetTy &BoxedLoops) { - while (BoxedLoops.count(L)) - L = L->getParentLoop(); - return L; -} - static cl::opt ModelReadOnlyScalars( "polly-analyze-read-only-scalars", cl::desc("Model read-only scalar values in the scop description"), Index: polly/trunk/lib/Analysis/ScopInfo.cpp =================================================================== --- polly/trunk/lib/Analysis/ScopInfo.cpp +++ polly/trunk/lib/Analysis/ScopInfo.cpp @@ -2304,18 +2304,6 @@ return true; } -// If the loop is nonaffine/boxed, return the first non-boxed surrounding loop -// for Polly. If the loop is affine, return the loop itself. Do not call -// `getSCEVAtScope()` on the result of `getFirstNonBoxedLoopFor()`, as we need -// to analyze the memory accesses of the nonaffine/boxed loops. -static Loop *getFirstNonBoxedLoopFor(BasicBlock *BB, LoopInfo &LI, - const BoxedLoopsSetTy &BoxedLoops) { - auto *L = LI.getLoopFor(BB); - while (BoxedLoops.count(L)) - L = L->getParentLoop(); - return L; -} - /// Adjust the dimensions of @p Dom that was constructed for @p OldL /// to be compatible to domains constructed for loop @p NewL. /// Index: polly/trunk/lib/Support/ScopHelper.cpp =================================================================== --- polly/trunk/lib/Support/ScopHelper.cpp +++ polly/trunk/lib/Support/ScopHelper.cpp @@ -571,3 +571,17 @@ return std::make_tuple(Subscripts, Sizes); } + +llvm::Loop *polly::getFirstNonBoxedLoopFor(llvm::Loop *L, llvm::LoopInfo &LI, + const BoxedLoopsSetTy &BoxedLoops) { + while (BoxedLoops.count(L)) + L = L->getParentLoop(); + return L; +} + +llvm::Loop *polly::getFirstNonBoxedLoopFor(llvm::BasicBlock *BB, + llvm::LoopInfo &LI, + const BoxedLoopsSetTy &BoxedLoops) { + Loop *L = LI.getLoopFor(BB); + return getFirstNonBoxedLoopFor(L, LI, BoxedLoops); +}