<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi,</div><div dir="ltr"><br></div><div>I have problems to estimate the loop exit count of a simple loop with the ScalarEvolution class.</div><div><br></div><div>simple loop:<br></div><div>
<font size="2">......<br> int a = 0;<br> for(int i; i < 10; ++i){<br> a = a + 1;<br> };<br></font></div><div>
<font size="2">......<br></font>
</div><div><br></div><div>For the loop analyzation I use the ScalarEvolution
class with the following initialization:<br>
<font size="2">......<br>void analysis(Function* func)</font><br> DominatorTree DT = DominatorTree();<br> DT.recalculate(*func);<br> DT.updateDFSNumbers();<br> <br> LoopInfoBase<BasicBlock, Loop> LIB;<br> LIB.releaseMemory();<br> LIB.analyze(DT);<br> <br> for(auto&bb :*func){<br> Loop * L = LIB.getLoopFor(&bb);<br> if(L != nullptr){<br> AssumptionCache AC = AssumptionCache(*bb.getParent());<br> Triple MT(llvm::sys::getDefaultTargetTriple());<br> TargetLibraryInfoImpl TLII(MT);<br> TargetLibraryInfoWrapperPass TLI = TargetLibraryInfoWrapperPass(TLII);<br> <br> LoopInfo LI = LoopInfo(DT);<br> LI.analyze(DT);<br> <br> <b>ScalarEvolution SE = ScalarEvolution(*func, TLI.getTLI(),AC, DT, LI);</b><br> BasicBlock * exitingblock = L->getUniqueExitBlock();<br> const SCEV * exitingcount = SE.getExitCount (L,exitblock );<br> }<br> }</div><div>}<br></div><div>
<font size="2">......</font> <br></div><div><br></div><div>Unfortunately I get this result by printing the SCEV
exitingcount variable:</div><div>
***COULDNOTCOMPUTE*** <br></div><div><br></div><div>
It has been tested that the exitingblock of the loop was calculated successfully.<br>
</div><div>The LLVM IR is parsed and analysed without the usual pass framework. For this reason <br></div><div>the use of the getAnalysis<ScalarEvolution>() is not possible. The question is wether there</div><div>is something I`m doing wrong during the initialization of the
ScalarEvolution
class? Or is</div><div> the use of LLVM analysis classes without the passmanager framework not possible?<br></div><div><br></div><div>Best regards!<br></div><div>Benedikt<br></div><div dir="ltr"><br><br></div></div></div></div>