Dong Chen via llvm-dev
2016-Aug-03 22:42 UTC
[llvm-dev] why LoopInfoWrapperPass can not detect all the canonical loops?
The original cl code contains 2 canonical loops (start from 0 with stride 1). But the analysis pass LoopInfoWrapperPass only detect one of them, anybody knows why? The analysis pass LoopInfoWrapperPass is called from a function pass by the following statements: LoopInfo& LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo(); for(LoopInfo::iterator l = LI.begin(), lend = LI.end(); l != lend; ++l){ PHINode* phi = (*l)->getCanonicalInductionVariable(); } -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160803/a5279e0b/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: stencil.cl Type: application/octet-stream Size: 683 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160803/a5279e0b/attachment.obj> -------------- next part -------------- A non-text attachment was scrubbed... Name: stencil.ll Type: application/octet-stream Size: 5275 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160803/a5279e0b/attachment-0001.obj>
Mikhail Zolotukhin via llvm-dev
2016-Aug-04 00:56 UTC
[llvm-dev] why LoopInfoWrapperPass can not detect all the canonical loops?
Hi Dong, The LI provides iterator for top-level loops. In your test you have only one top-level loop, the other one is nested in it. Here is what the loop structure looks like for your test: $ opt -loops -analyze stencil.ll Printing analysis 'Natural Loop Information' for function 'stencil': Loop at depth 1 containing: %for.body<header>,%for.body8.lr.ph,%for.body8,%for.cond.cleanup7.loopexit,%for.cond.cleanup7<latch><exiting> Loop at depth 2 containing: %for.body8<header><latch><exiting> There are a number of passes that walk through all loops in a function, you could look at them if you need an example. For example, loop-vectorizer does this: SmallVector<Loop *, 8> Worklist; for (Loop *L : *LI) addInnerLoop(*L, Worklist); ... static void addInnerLoop(Loop &L, SmallVectorImpl<Loop *> &V) { if (L.empty()) return V.push_back(&L); for (Loop *InnerL : L) addInnerLoop(*InnerL, V); } Hope this helps! Michael> On Aug 3, 2016, at 3:42 PM, Dong Chen via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > The original cl code contains 2 canonical loops (start from 0 with stride 1). But the analysis pass LoopInfoWrapperPass only detect one of them, anybody knows why? > > The analysis pass LoopInfoWrapperPass is called from a function pass by the following statements: > > LoopInfo& LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo(); > for(LoopInfo::iterator l = LI.begin(), lend = LI.end(); l != lend; ++l){ > PHINode* phi = (*l)->getCanonicalInductionVariable(); > } > <stencil.cl><stencil.ll>_______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160803/8dc5bdca/attachment.html>