Hi guys,<br><br>I am trying to use the indvars pass, but i don't see any changes in the IL representation.<br><br>For this simple function<br><br>void init_array(int k)<br>{ <br> int A[20];<br> for (int i=2; i<10; i++)<br>
A[i] = 0;<br>}<br><br>i run <b>clang test-simple.c -S -emit-llvm -o <a href="http://test.il">test.il</a></b> and i obtain the following il representation<br><br>define void @init_array(i32 %k) nounwind {<br>entry:<br>
%k.addr = alloca i32, align 4<br> %A = alloca [20 x i32], align 4<br> %i = alloca i32, align 4<br> store i32 %k, i32* %k.addr, align 4<br> store i32 2, i32* %i, align 4<br> br label %for.cond<br><br>for.cond: ; preds = %for.inc, %entry<br>
%tmp = load i32* %i, align 4<br> %cmp = icmp slt i32 %tmp, 10<br> br i1 %cmp, label %for.body, label %for.end<br><br>for.body: ; preds = %for.cond<br> %tmp1 = load i32* %i, align 4<br>
%arrayidx = getelementptr inbounds [20 x i32]* %A, i32 0, i32 %tmp1<br> store i32 0, i32* %arrayidx, align 4<br> br label %for.inc<br><br>for.inc: ; preds = %for.body<br> %tmp2 = load i32* %i, align 4<br>
%inc = add nsw i32 %tmp2, 1<br> store i32 %inc, i32* %i, align 4<br> br label %for.cond<br><br>for.end: ; preds = %for.cond<br> ret void<br>}<br><br>Running <b>opt -loop-simplify < <a href="http://test.il">test.il</a> -S</b> gives me the same output, which is what i would expect.<br>
The problem is that running <b>opt -indvars < <a href="http://test.il">test.il</a> -S</b> gives, again, the same output, but i would expect that i starts from 0 and is, eventualy, defined using a PHYNode.<br><br>What it's wrong with what i'm doing?<br>
<br>Thank you.<br>Have a nice day<br><br><br><br><br><br>