[PATCH] D21665: [LoopSimplify] Update LCSSA after separating nested loops.
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 27 14:03:38 PDT 2016
sanjoy added inline comments.
================
Comment at: lib/Transforms/Utils/LoopSimplify.cpp:353
@@ +352,3 @@
+ for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
+ Instruction *V = dyn_cast<Instruction>(PN->getIncomingValue(i));
+ if (!V || !L->contains(V))
----------------
s/V/I/
================
Comment at: lib/Transforms/Utils/LoopSimplify.cpp:370
@@ +369,3 @@
+ NewPN->addIncoming(V, PredBB);
+ PN->setIncomingValue(i, NewPN);
+ break;
----------------
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.
http://reviews.llvm.org/D21665
More information about the llvm-commits
mailing list