[PATCH] D21665: [LoopSimplify] Update LCSSA after separating nested loops.
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 28 17:34:52 PDT 2016
sanjoy added inline comments.
================
Comment at: lib/Transforms/Utils/LoopSimplify.cpp:370
@@ +369,3 @@
+ NewPN->addIncoming(V, PredBB);
+ PN->setIncomingValue(i, NewPN);
+ break;
----------------
sanjoy wrote:
> What if you have
>
> ```
> loop:
> %iv = phi [ 0, %entry ] [ %iv, (%loop, %left, %right)], [ %iv.inc, %outer ]
> %iv.inc = %iv + 1
> switch(condition), %left, %right, %loop
>
> left:
> br condition, %outer, %loop
>
> right:
> br condition, %outer, %loop
>
> outer:
> br %loop
> ```
>
> then the separated loop structure will be
>
> ```
> outer_header:
> %iv = [ 0, %entry ] , [ %iv.inc, %outer ]
> br loop
>
> loop:
> %iv.inc = %iv + 1
> switch(condition), %left, %right, %loop
>
> left:
> br condition, %outer, %loop
>
> right:
> br condition, %outer, %loop
>
> outer:
> br %loop
> ```
>
> Now %iv.inc is live out of the inner loop and none of the inner loop
> exits (%left, %right) dominate %outer.
Nit: the latter code snippet should be
```
outer_header:
%iv = [ 0, %entry ] , [ %iv.inc, %outer ]
br loop
loop:
%iv.inc = %iv + 1
switch(condition), %left, %right, %loop
left:
br condition, %outer, %loop
right:
br condition, %outer, %loop
outer:
br %outer_header
```
http://reviews.llvm.org/D21665
More information about the llvm-commits
mailing list