Tidy up getFirstNonBoxedLoopFor [NFC]

Move the function getFirstNonBoxedLoopFor which is used in ScopBuilder
and in ScopInfo to Support/ScopHelpers to make it reusable in other
locations. No functionality change.

Patch by Sameer Abu Asal.

Differential Revision: https://reviews.llvm.org/D28754

llvm-svn: 292168
This commit is contained in:
Eli Friedman 2017-01-16 22:54:29 +00:00
parent 6cc726ead0
commit 71329901ea
4 changed files with 33 additions and 23 deletions

View File

@ -435,5 +435,24 @@ llvm::BasicBlock *getUseBlock(llvm::Use &U);
std::tuple<std::vector<const llvm::SCEV *>, std::vector<int>>
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

View File

@ -31,17 +31,6 @@ STATISTIC(RichScopFound, "Number of Scops containing a loop");
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<bool> ModelReadOnlyScalars(
"polly-analyze-read-only-scalars",
cl::desc("Model read-only scalar values in the scop description"),

View File

@ -2304,18 +2304,6 @@ bool Scop::buildDomains(Region *R, DominatorTree &DT, LoopInfo &LI) {
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.
///

View File

@ -571,3 +571,17 @@ polly::getIndexExpressionsFromGEP(GetElementPtrInst *GEP, ScalarEvolution &SE) {
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);
}