[LLVMdev] SimplifyCFG vs loops

Krzysztof Parzyszek kparzysz at codeaurora.org
Wed Oct 17 10:03:28 PDT 2012

On 10/17/2012 11:55 AM, Chris Lattner wrote:
> On Oct 17, 2012, at 9:38 AM, Krzysztof Parzyszek <kparzysz at codeaurora.org> wrote:
>> There is no reason for two back edges.  This loop could look like this:
>> header:
>>   ...
>>   ...
>>   if (cond) goto tail; else goto next;
>> next:
>>   ...
>> tail:
>>   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.
> What problem does that solve?  LLVM's concept of loop is tied to the loop header block: this both forms are a single loop, not two nested loops.

There are two back-edges that both go to the same header.  It was a 
while ago, but I saw some procedure that tried to eliminate such cases 
by separating the two back edges into their own loops.  We ended up with 
two loops instead of only having one.

I'd have to dig up the old testcase I working on, but the code there was 
getting unnecessarily complicated due to the fact that SimplifyCFG was 
making changes that eventually hurt loop optimizations.

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

More information about the llvm-dev mailing list