[LLVMdev] SCEV cannot derive number of loop iterations

Tobias Grosser tobias at grosser.es
Wed Dec 14 04:10:01 PST 2011


Hi,

I am looking at two very simple kernels. They implement the following loops:

constant_bound():
	for (int i = 0; i < 100; i+=4);

parameteric_bound():
	for (int i = 0; i < n; i+=4);

For the first loop SCEV is able to derive the number of loop iterations,
for the second loop it returns 'Unpredictable backedge-taken count'.

Is this expected because it is a difficult problem or is this just a 
missed-analysis? Any ideas what is needed to detect this case?

Also, I am surprised that SCEV misses the nsw/nuw flags in this case:

   %tmp = mul nuw nsw i64 %indvar, 4
   -->  {0,+,4}<%for.body>		Exits: <<Unknown>>

Cheers
Tobi

P.S.: LLVM-IR test case attached.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: could_not_compute.ll
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111214/fe6cb6a1/attachment.ksh>


More information about the llvm-dev mailing list