[LLVMdev] Loop transformations using LLVM

Rotem, Nadav nadav.rotem at intel.com
Thu May 5 05:11:16 PDT 2011


Malveeka, 

You can use the LoopInfo analysis to find the induction variable. 

http://llvm.org/docs/doxygen/html/classllvm_1_1Loop.html#a72bbf45d2e00971f56bf8cfe4e1df01c

Cheers,
Nadav


From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Malveeka Tewari
Sent: Thursday, May 05, 2011 14:51
To: llvmdev at cs.uiuc.edu
Subject: [LLVMdev] Loop transformations using LLVM

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
---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.




More information about the llvm-dev mailing list