[LLVMdev] Loop transformations using LLVM

Malveeka Tewari mtewari at eng.ucsd.edu
Thu May 5 04:50:57 PDT 2011


Hi

I am trying to write up a transformation for the following code where
instead of incrementing the loop variable by 1, I increment it by 2 ie.

for (i=0; i < THRES; *i++*) {
  //do something
}

gets transformed to

for (i=0; i < THRES; *i+=2*) {
  //do something
}

I am thinking of transforming the llvm  bit-code in the following way.
Iterate over the function for the original code till I get the basicBlock
for the for loop, then iterate over the instructions till I get the
increment instruction and then add the same increment instruction so that
the increment happens twice.

I am still getting familiar with the llvm infrastructure and I am not sure
if the above approach is even going to work. It'll be great if someone can
suggest a better or more concrete way of doing the above transformation ? Is
there already something similar in the source tree  that can I look up for
ideas ?

Thanks!
Malveeka
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110505/0edf031c/attachment.html>


More information about the llvm-dev mailing list