<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Dong,<div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">Here is what the loop structure looks like for your test:</div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div class=""><font face="Menlo" class="">$ opt -loops -analyze stencil.ll</font></div></div><div class=""><div class=""><font face="Menlo" class="">Printing analysis 'Natural Loop Information' for function 'stencil':</font></div></div><div class=""><div class=""><font face="Menlo" class="">Loop at depth 1 containing: %for.body<header>,%for.body8.lr.ph,%for.body8,%for.cond.cleanup7.loopexit,%for.cond.cleanup7<latch><exiting></font></div></div><div class=""><div class=""><font face="Menlo" class="">    Loop at depth 2 containing: %for.body8<header><latch><exiting></font></div></div></blockquote><div class=""><br class=""></div><div class="">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:</div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Menlo" class="">SmallVector<Loop *, 8> Worklist;</font></div><div class=""><font face="Menlo" class="">for (Loop *L : *LI)</font></div><div class=""><font face="Menlo" class="">  addInnerLoop(*L, Worklist);</font></div><div class=""><font face="Menlo" class="">...</font></div><div class=""><div class=""><font face="Menlo" class=""><br class=""></font></div></div><div class=""><div class=""><font face="Menlo" class="">static void addInnerLoop(Loop &L, SmallVectorImpl<Loop *> &V) {</font></div></div><div class=""><div class=""><font face="Menlo" class="">  if (L.empty())</font></div></div><div class=""><div class=""><font face="Menlo" class="">    return V.push_back(&L);</font></div></div><div class=""><div class=""><font face="Menlo" class=""><br class=""></font></div></div><div class=""><div class=""><font face="Menlo" class="">  for (Loop *InnerL : L)</font></div></div><div class=""><div class=""><font face="Menlo" class="">    addInnerLoop(*InnerL, V);</font></div></div><div class=""><div class=""><font face="Menlo" class="">}</font></div></div></blockquote><div class=""><br class=""></div><div class="">Hope this helps!</div><div class=""><br class=""></div><div class="">Michael</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On Aug 3, 2016, at 3:42 PM, Dong Chen via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">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?<div class=""><br class=""></div><div class="">The analysis pass LoopInfoWrapperPass is called from a function pass by the following statements:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Monaco; color: rgb(77, 186, 43); background-color: rgb(0, 0, 0);" class=""><span style="" class="">LoopInfo& LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();</span></div><div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Monaco; color: rgb(77, 186, 43); background-color: rgb(0, 0, 0);" class=""><span style="color:rgb(206,121,36)" class="">for</span><span style="" class="">(LoopInfo::iterator l = LI.begin(), lend = LI.end(); l != lend; ++l){</span></div><div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Monaco; color: rgb(77, 186, 43); background-color: rgb(0, 0, 0);" class=""><span style="" class="">    PHINode* phi = (*l)->getCanonicalInductionVariable();</span></div><div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Monaco; color: rgb(77, 186, 43); background-color: rgb(0, 0, 0);" class=""><span style="" class="">}</span></div></div></div>
<span id="cid:C24D3919-0E06-4D4B-9743-348453048297@apple.com"><stencil.cl></span><span id="cid:45F93D6B-AB82-4F5B-BBF0-B46BEC81BE49@apple.com"><stencil.ll></span>_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></blockquote></div><br class=""></div></body></html>