[LLVMdev] Loop unroll pass (was: Re: Speculative phi elimination at the top of a loop?)

Pekka Nikander pekka.nikander at nomadiclab.com
Tue Sep 21 03:23:08 PDT 2010


>>  Would the best way be to add an option to -loop-unroll, and hack away at lib/Transforms/Utils/LoopUnroll.cpp?
> 
> Instead, the better alternative is to write another pass similar to
> LoopUnrollPass.cpp (say LoopPeelPass.cpp) and add new option
> -loop-peel. The new pass could use llvm::UnrollLoop() utility
> function. Feel free to adjust this utility function if required, but
> the core utility function should be used by both passes

It took some time (mainly because of the rest of the project), but I have now an early version of LoopPeelPass.cpp implemented.  It uses the llvm::UnrollPass() utility function; I added one argument, "bool Peeling", to the UnrollPass() function, with the default value of "false".

There still some problems related to the block merging in the end of llvm::UnrollPass(), but otherwise it seems to work. 

I'm afraid it will take some more time before I have a good and clean patch ready, but in the mean time if anyone would like to review the changed, I'd be more than happy to send a diff off-list.

--Pekka







More information about the llvm-dev mailing list