loop transformation: uniquely identifying a loop within a program

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

loop transformation: uniquely identifying a loop within a program

Tatenda M. Chipeperekwa
hi all,

We are writing a loop transformation using the llvm loop pass class, but we do not want to run the pass on all loops within a program. We are looking for suggestions on how we can uniquely identify certain loops that we want to transform. So far, we are working on a suggestion to transform the loops depending on which function they're run from in the program. Which will be something like this:

   ... 
   Function *F = L -> getParent() -> getParent();
...
   if(F->getName == "my_function") {
   //transform loops in my_function
   }

The function name can easily be passed in from the command line and this would work fine for loops within that function only. But how can we extend this for nested loops for example?

Thank you,

tatenda
 

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: loop transformation: uniquely identifying a loop within a program

Devang Patel

On Nov 10, 2011, at 2:39 AM, Tatenda M. Chipeperekwa wrote:

hi all,

We are writing a loop transformation using the llvm loop pass class, but we do not want to run the pass on all loops within a program. We are looking for suggestions on how we can uniquely identify certain loops that we want to transform. So far, we are working on a suggestion to transform the loops depending on which function they're run from in the program. Which will be something like this:

   ... 
   Function *F = L -> getParent() -> getParent();
...
   if(F->getName == "my_function") {
   //transform loops in my_function
   }

The function name can easily be passed in from the command line and this would work fine for loops within that function only. But how can we extend this for nested loops for example?

you can use if (L->getHeader()->getParent()->getNames() == "special_function") check, which will work for all loops.

-
Devang


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: loop transformation: uniquely identifying a loop within a program

Tatenda M. Chipeperekwa
hi,

thank you for the response, we managed to get all the loops in a given function using this:
 
you can use if (L->getHeader()->getParent()->getNames() == "special_function") check, which will work for all loops.


As part of the transformation we need to get information about the loops, and we are using the LoopInfo pass:

LI = &getAnalysis<LoopInfo>();

to get information such as the depth of the loop. We are also manipulating the IV in some instances e.g. changing the step from say 1 to 2, and we have implemented this by iterating through all the instructions in a BB. It seems that the best approach to do this would be to use the ScalarEvolution, which we have added to our pass:

SE = getAnalysisIfAvailable<ScalarEvolution>();

We been going through the LoopStrengthReduce pass but are unable to implement this correctly, and to re-write the IR for these cases. Any pointers on how to do this are appreciated. 

Regards,

tatenda

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev