summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/LoopUnroll.cpp
diff options
context:
space:
mode:
authorDinesh Dwivedi <dinesh.d@samsung.com>2014-05-29 06:47:23 +0000
committerDinesh Dwivedi <dinesh.d@samsung.com>2014-05-29 06:47:23 +0000
commit2a747bf1c566cbe9739f2a687bc093fdd5cfeda0 (patch)
treec88862f72922d4216c23484790ee58cbe3ac4606 /lib/Transforms/Utils/LoopUnroll.cpp
parented0e90576d3e0b4796aa7825320cf4d41745f81e (diff)
downloadllvm-2a747bf1c566cbe9739f2a687bc093fdd5cfeda0.tar.gz
llvm-2a747bf1c566cbe9739f2a687bc093fdd5cfeda0.tar.bz2
llvm-2a747bf1c566cbe9739f2a687bc093fdd5cfeda0.tar.xz
LCSSA should be performed on the outermost affected loop while unrolling loop.
During loop-unroll, loop exits from the current loop may end up in in different outer loop. This requires to re-form LCSSA recursively for one level down from the outer most loop where loop exits are landed during unroll. This fixes PR18861. Differential Revision: http://reviews.llvm.org/D2976 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209796 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/LoopUnroll.cpp')
-rw-r--r--lib/Transforms/Utils/LoopUnroll.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Transforms/Utils/LoopUnroll.cpp b/lib/Transforms/Utils/LoopUnroll.cpp
index d953e30731..16975b9e63 100644
--- a/lib/Transforms/Utils/LoopUnroll.cpp
+++ b/lib/Transforms/Utils/LoopUnroll.cpp
@@ -487,6 +487,15 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, unsigned TripCount,
if (OuterL) {
ScalarEvolution *SE = PP->getAnalysisIfAvailable<ScalarEvolution>();
simplifyLoop(OuterL, DT, LI, PP, /*AliasAnalysis*/ nullptr, SE);
+
+ // LCSSA must be performed on the outermost affected loop. The unrolled
+ // loop's last loop latch is guaranteed to be in the outermost loop after
+ // deleteLoopFromQueue updates LoopInfo.
+ Loop *LatchLoop = LI->getLoopFor(Latches.back());
+ if (!OuterL->contains(LatchLoop))
+ while (OuterL->getParentLoop() != LatchLoop)
+ OuterL = OuterL->getParentLoop();
+
formLCSSARecursively(*OuterL, *DT, SE);
}
}