Martin Apel
2012-Jun-05 10:20 UTC
[LLVMdev] How to unroll loops in opposite loop nest order
I am trying to implement loop unrolling in a context, where lots of constant propagation has taken place. Unrolling an outer loop might make an inner loop have constant bounds, therefore I want to process the loops outside in, i.e. from parent loops to nested loops. Unfortunately the standard loop pass manager performs loop passes inside out, i.e. from nested loops to parent loops, thereby missing optimization opportunities in my case. I haven't found a way how to implement this on my own. I tried implementing a function pass, where I could process the loops outside in. Unfortunately I cannot use the UnrollLoop utility function in this case, which crashes, when called with a NULL LPPassManager object, despite opposite documentation. Is there any way how to process loops outside in still using the UnrollLoop function? Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120605/8d943358/attachment.html>
Andrew Trick
2012-Jun-05 18:11 UTC
[LLVMdev] How to unroll loops in opposite loop nest order
On Jun 5, 2012, at 3:20 AM, Martin Apel <martin.apel at SIMPACK.de> wrote:> I am trying to implement loop unrolling in a context, where lots of constant propagation has taken place. > Unrolling an outer loop might make an inner loop have constant bounds, therefore I want to process the loops > outside in, i.e. from parent loops to nested loops. > Unfortunately the standard loop pass manager performs loop passes inside out, i.e. from nested loops to parent loops, > thereby missing optimization opportunities in my case. > > I haven't found a way how to implement this on my own. I tried implementing a function pass, where I could process the > loops outside in. Unfortunately I cannot use the UnrollLoop utility function in this case, which crashes, when called with a > NULL LPPassManager object, despite opposite documentation. > > Is there any way how to process loops outside in still using the UnrollLoop function?I noticed another case of referencing LPM without a null check and fixed it here r158007. You'll should be careful to check everything that's currently disabled when LPM is missing: domtree update, ScalarEvolution update, SimplifyIndvar. If you need any of these things I suggest changing the interface. Maybe it would work to pass in FunctionPass instead of LPM. In the one place we actually need an LPM (deleteLoopFromQueue), we could check FunctionPass's type and cast. Maybe getAsPMDataManager()->getPassManagerType() == PMT_LoopPassManager? -Andy -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120605/d1df85f8/attachment.html>
Martin Apel
2012-Jun-08 13:08 UTC
[LLVMdev] How to unroll loops in opposite loop nest order
Hi Andy, sorry, my mail wasn't precise enough: I am trying to do this in a plugin, i.e. in a LLVM client. I try to do this without modifying LLVM itself. In the meantime I have found a way to do it the way I need it. I only consider top-level loops in my LoopPass and add the child loops again using LPPassManager::insertLoopIntoQueue. This seems to have the desired effect. Martin On 05/06/12 20:11, Andrew Trick wrote:> > On Jun 5, 2012, at 3:20 AM, Martin Apel <martin.apel at SIMPACK.de > <mailto:martin.apel at SIMPACK.de>> wrote: > >> I am trying to implement loop unrolling in a context, where lots of >> constant propagation has taken place. >> Unrolling an outer loop might make an inner loop have constant >> bounds, therefore I want to process the loops >> outside in, i.e. from parent loops to nested loops. >> Unfortunately the standard loop pass manager performs loop passes >> inside out, i.e. from nested loops to parent loops, >> thereby missing optimization opportunities in my case. >> >> I haven't found a way how to implement this on my own. I tried >> implementing a function pass, where I could process the >> loops outside in. Unfortunately I cannot use the UnrollLoop utility >> function in this case, which crashes, when called with a >> NULL LPPassManager object, despite opposite documentation. >> >> Is there any way how to process loops outside in still using the >> UnrollLoop function? > > I noticed another case of referencing LPM without a null check and > fixed it here r158007. > > You'll should be careful to check everything that's currently disabled > when LPM is missing: domtree update, ScalarEvolution update, > SimplifyIndvar. If you need any of these things I suggest changing the > interface. > > Maybe it would work to pass in FunctionPass instead of LPM. In the one > place we actually need an LPM (deleteLoopFromQueue), we could check > FunctionPass's type and cast. > Maybe getAsPMDataManager()->getPassManagerType() == PMT_LoopPassManager? > > -Andy-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120608/7660456d/attachment.html>
Maybe Matching Threads
- [LLVMdev] How to unroll loops in opposite loop nest order
- [LLVMdev] Dragonegg + IR + llc = Dragonegg directly
- [LLVMdev] Dragonegg + IR + llc = Dragonegg directly
- [LLVMdev] Missing optimization in constant propagation?
- [LLVMdev] Dragonegg + IR + llc = Dragonegg directly