<div dir="ltr">Hi,<div><br></div><div><div style="font-size:12.8px">I am trying to do loop unrolling with loops that don't have constant loop counter. It is highly appreciated if anyone can help me on this.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">What I want to do is to turn</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">   <font color="#0000ff"> loop (n)</font></div><div style="font-size:12.8px"><font color="#0000ff">    {</font></div><div style="font-size:12.8px"><font color="#0000ff">      <loop body></font></div><div style="font-size:12.8px"><font color="#0000ff">    }</font></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">into</div><div style="font-size:12.8px"><div><br></div><div>   <font color="#0000ff"> loop (n/4)</font></div><div><font color="#0000ff">    {</font></div><div><font color="#0000ff">      <loop body></font></div><div><font color="#0000ff">      <loop body></font></div><div><font color="#0000ff">      <loop body></font></div><div><font color="#0000ff">      <loop body></font></div><div><font color="#0000ff">    }<br></font></div></div><div style="font-size:12.8px"><div><font color="#0000ff">    loop (n%4)</font></div><div><font color="#0000ff">    {</font></div><div><font color="#0000ff">      <loop body></font></div></div><div style="font-size:12.8px"><font color="#0000ff">    }</font></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I set allowPartial and Runtime to both 1 ( llvm::createLoopUnrollPass(Threshold, count, 1, 1) )</div><div style="font-size:12.8px">Also overload the UnrollingPreferences structure to gives values to all the Partial* members, but the loop still doesn't unroll.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">The unrolling process hits this code in LoopUnrollRuntime.cpp</div><div style="font-size:12.8px"><font color="#38761d"><br></font></div><div style="font-size:12.8px"><div><font color="#38761d"> </font><font color="#93c47d"> // Only unroll loops with a computable trip count and the trip count needs</font></div><div><font color="#93c47d">  // to be an int value (allowing a pointer type is a TODO item)</font></div><div><font color="#93c47d">  const SCEV *BECountSC = SE->getBackedgeTakenCount(L);</font></div><div><font color="#93c47d">  if (isa<SCEVCouldNotCompute>(BECountSC) ||</font></div><div><font color="#93c47d">      !BECountSC->getType()->isIntegerTy())</font></div><div><font color="#93c47d">    return false;</font></div></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">BECountSC=0xcccccccc and returns false here.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Based on the comments it looks like I still need a constant loop counter. Is there a way to unroll with non-constant loop counter as in the example above?</div></div><div><br></div><div>Thanks,</div><div>Frances</div></div>