Madhur Amilkanthwar via llvm-dev
2016-Oct-16 10:38 UTC
[llvm-dev] Induction variable identification?
Hi, How does LLVM identify induction variables of a loop? Is the algorithm based on SSA graphs? I have a complicated loop and I need to do some analysis around it. Can anyone please point me to source of identification part? -- *Disclaimer: Views, concerns, thoughts, questions, ideas expressed in this mail are of my own and my employer has no take in it. * Thank You. Madhur D. Amilkanthwar -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161016/783ff3ed/attachment.html>
Ehsan Amiri via llvm-dev
2016-Oct-16 16:48 UTC
[llvm-dev] Induction variable identification?
If you have a canonicalized IV, you can use Loop::getCanonicalInductionVariable() declared in "include/llvm/Analysis/LoopInfo.h". Otherwise you probably need to start from function simplifyLoopIVs() in "lib/Transforms/Utils/SimplifyIndVar.cpp". This method looks at all phi nodes in the header of the loop, but later on in the process, it skips some of them. For example, when we reach SimplifyIndvar::simplifyUsers(), in the beginning of this function we check if the IV data type isSCEVable() or not. If not, we immediately return. Hope that helps Ehsan On Sun, Oct 16, 2016 at 6:38 AM, Madhur Amilkanthwar via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi, > How does LLVM identify induction variables of a loop? > Is the algorithm based on SSA graphs? > > I have a complicated loop and I need to do some analysis around it. > Can anyone please point me to source of identification part? > > > > -- > *Disclaimer: Views, concerns, thoughts, questions, ideas expressed in this > mail are of my own and my employer has no take in it. * > Thank You. > Madhur D. Amilkanthwar > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161016/23f88a0d/attachment.html>
Sanjoy Das via llvm-dev
2016-Oct-16 17:13 UTC
[llvm-dev] Induction variable identification?
Hi Madhur, If you're looking to solely _analyze_ induction variables, maybe you should try leveraging LLVM's "Scalar Evolution" framework? See include/llvm/Analysis/ScalarEvolution.h for the docs or the IndVarSimplify pass for examples. Thanks, -- Sanjoy
Ehsan Amiri via llvm-dev
2016-Oct-16 17:49 UTC
[llvm-dev] Induction variable identification?
To be clear, I was suggesting to read the code in simplifyLoopIVs() in "lib/Transforms/Utils/SimplifyIndVar.cpp" to see how it identifies IVs. (as opposed to calling the function to change the code). On Sun, Oct 16, 2016 at 12:48 PM, Ehsan Amiri <ehsanamiri at gmail.com> wrote:> If you have a canonicalized IV, you can use Loop:: > getCanonicalInductionVariable() declared in "include/llvm/Analysis/ > LoopInfo.h". > > Otherwise you probably need to start from function simplifyLoopIVs() in > "lib/Transforms/Utils/SimplifyIndVar.cpp". This method looks at all phi > nodes in the header of the loop, but later on in the process, it skips some > of them. For example, when we reach SimplifyIndvar::simplifyUsers(), in > the beginning of this function we check if the IV data type isSCEVable() or > not. If not, we immediately return. > > Hope that helps > Ehsan > > > On Sun, Oct 16, 2016 at 6:38 AM, Madhur Amilkanthwar via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >> Hi, >> How does LLVM identify induction variables of a loop? >> Is the algorithm based on SSA graphs? >> >> I have a complicated loop and I need to do some analysis around it. >> Can anyone please point me to source of identification part? >> >> >> >> -- >> *Disclaimer: Views, concerns, thoughts, questions, ideas expressed in >> this mail are of my own and my employer has no take in it. * >> Thank You. >> Madhur D. Amilkanthwar >> >> >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161016/c96bdf71/attachment.html>