[LLVMdev] Replacing a repetitive sequence of code with a loop

Philip Reames listmail at philipreames.com
Wed Jun 3 13:28:40 PDT 2015



On 06/03/2015 01:13 PM, Renato Golin wrote:
> On 3 June 2015 at 19:57, Benjamin Kramer <benny.kra at gmail.com> wrote:
>> There's a loop reroll pass in LLVM trunk that should do exactly this transformation.
> Though that's a loop pass (runOnLoop). What you could do is add a
> previous pass that would recognize the pattern and create a loop of 1
> iteration around the code and then run the reroll pass.
This sounds like we should need a separate pass which forms loops from 
straight line code.  I would strongly suggest only forming loops when 
you can find at least two iterations.  We can probably share most of the 
code with the existing reroller, but the wrapper pass needs a slightly 
different interface.
>
> If your pattern recognition is too good, it'll be redundant with the
> reroll pass, so I'm not sure how to do that without duplicating effort
> or destroying the IR (in case you're wrong). Adding 1-iteration loops
> to all functions won't work either. You'll have to balance the
> heuristics and make the pass optional, maybe with a pragma to help the
> compiler.
>
> cheers,
> --renato
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list