[LLVMdev] A question about induction variables

Vladimir Prus ghost at cs.msu.su
Wed Mar 31 09:17:03 PST 2004


Hello,
I've just downloaded the latest release of LLVM, and playing with the 
following simple example:

int main()
{
    int r(0);
    for (int i = 0; i < 100; ++i)
        r += i;
        ;
    return r;
}

I compile it and then run:

   analyze -indvars x.bc

which prints:

   Printing analysis 'Induction Variable Analysis' for function 'main':

and nothing else. It is a bit strange -- since 'i' is clearly an induction 
variable and the resulting loop in assembler should have some induction 
variable too. Does this mean that induction variable analysis is not fully 
implemented, or there's some error on my part?

If I don't use the 'r' variable, but just loop with empty body, the entire 
loop seems to be optimized out, but in this example the loop is still there 
in assembler.

Thanks in advance,
Volodya




More information about the llvm-dev mailing list