[LLVMdev] SimplifyCFG vs loops

Krzysztof Parzyszek kparzysz at codeaurora.org
Wed Oct 17 09:38:28 PDT 2012

On 10/17/2012 11:09 AM, Dan Gohman wrote:
> On Wed, Oct 17, 2012 at 8:41 AM, Krzysztof Parzyszek
> <kparzysz at codeaurora.org <mailto:kparzysz at codeaurora.org>> wrote:
>     Hello All,
>     The current implementation of the CFG simplification is
>     loop-agnostic. In the past I have observed that it can perform
>     transformations that can be detrimental to the loop structure.  One
>     example that I recall, is converting a loop like this:
>         while (...) {
>            ...
>            if (cond) continue;
>            ...
>         }
>     into two nested loops.  Specifically, the "continue" branch would go
>     back to the loop header making it appear as if there were two back
>     edges.
> Well, there really are two backedges there.

There is no reason for two back edges.  This loop could look like this:

   if (cond) goto tail; else goto next;
   if (loop-condition) goto header;

This way there is one loop with some control flow nested in it, instead 
of something that looks like two loops.

Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
hosted by The Linux Foundation

More information about the llvm-dev mailing list