[LLVMdev] SimplifyCFG vs loops

James Courtier-Dutton james.dutton at gmail.com
Wed Oct 17 12:11:54 PDT 2012

On 17 October 2012 16:41, Krzysztof Parzyszek <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.
> What are your thoughts about either making the CFG simplification aware of
> loops in its entirety, or separating the "safe" transformations in a quick
> pass, and having a more aggressive pass that does preserve loop structure?

Having two back edges does not have an adverse affect on optimisation.
Do you have a specific optimisation that you cannot do if there are
two back edges?
I thing to keep in mind is this is CFG, and can be unstructured, or
after various transformations, not representable in higher level
language structures such as while loops.

Kind Regards


More information about the llvm-dev mailing list