[LLVMdev] Unrolling a loop with unknown upper bound

Zhong Zheng zhengzhongnudt at gmail.com
Thu Jan 31 09:03:00 PST 2013


Hi all,

I am new to llvm. I want to leverage llvm to do some basic optimization. 

What I want to start is to unroll a loop with unkown upper bound. For example,

for (i = 0; i < n; i++)
  {
    y[i] = i;
  }

can be rewritten by the compiler as follows:

for (i = 0; i < (n % 2); i++)
  {
    y[i] = i;
  }

for ( ; i + 1 < n; i += 2) /* no initializer */
  {
    y[i] = i;
    y[i+1] = i+1; 
  }

I have read these llvm documents, but still not very clear where to start.

I think it could be done by writing a pass. But, I still confused.

Does there anynoe who can give me any advice.

Any information will be appreciated.

Thank you in avance!




More information about the llvm-dev mailing list