[llvm-commits] Patch to improve loop-simplify

Cameron Zwarich zwarich at apple.com
Thu Mar 3 00:43:38 PST 2011


When I compile your first test case without this patch for X86, I see 2 conditional branches in the loop body and no unconditional branches. With this patch, there is an extra unconditional branch inside the loop. Unfortunately, I don't think this is cleaned up as well as you assume.

Cameron

On 2011-03-02, at 11:56 PM, Andrew Clinton wrote:

> The role of the loop-simplify pass, as described in the header, is to
> transform natural loops into a simpler form.  The goal of this patch
> is not to produce the minimum number of instructions but to ensure
> that additional (unnecessary) complexity is not introduced by the
> simplification.  I think this is a good change since running the
> natural loops analysis after this pass will then produce the expected
> loop nesting.  Without this patch, I have found it necessary to write
> a new pass that merges the nested loops.
> 
> I believe that other passes will clean up extra branching (CFG
> simplification), and PHI nodes will usually add runtime complexity
> only for the incoming blocks.  So I wouldn't expect runtime
> performance to be impacted by this change.
> 
> Attached is the revised diff - thank you for the feedback!
> 
> Andrew
> 
> On Thu, Mar 3, 2011 at 2:10 AM, Cameron Zwarich <zwarich at apple.com> wrote:
>> Is splitting an edge to create a unique loop backedge better than creating two loops? If the inner loop's backedge is more frequently taken, then you are trading an extra unconditional branch (with phis) on loop entry for an extra unconditional branch (with phis) along the inner loop's backedge. When is this a good trade?
>> 
>> Cameron
> <nestedloops.diff>




More information about the llvm-commits mailing list