[LLVMdev] How to unroll loops in opposite loop nest order

Andrew Trick atrick at apple.com
Tue Jun 5 11:11:31 PDT 2012


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>


More information about the llvm-dev mailing list