From 61a8d3fb3314fb9993a429ef0c50a7cfcd3f5ebf Mon Sep 17 00:00:00 2001 From: Max Kazantsev Date: Thu, 17 Jan 2019 12:51:10 +0000 Subject: [LoopSimplifyCFG] Form LCSSA when a parent loop becomes a sibling During the transforms in LoopSimplifyCFG, when we remove a dead exiting edge, the parent loop may stop being reachable from the child loop, and therefore they become siblings. If the former child loop had uses of some values from its former parent loop, now such uses will require LCSSA Phis, even if they weren't needed before. So we must form LCSSA for all loops that stopped being ancestors of the current loop in this case. Differential Revision: https://reviews.llvm.org/D56144 Reviewed By: fedor.sergeev llvm-svn: 351434 --- llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp') diff --git a/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp b/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp index d51e6005d68..80690b8fadb 100644 --- a/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp +++ b/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp @@ -379,6 +379,15 @@ private: StillReachable->addChildLoop(&L); else LI.addTopLevelLoop(&L); + + // Some values from loops in [OuterLoop, StillReachable) could be used + // in the current loop. Now it is not their child anymore, so such uses + // require LCSSA Phis. + Loop *FixLCSSALoop = OuterLoop; + while (FixLCSSALoop->getParentLoop() != StillReachable) + FixLCSSALoop = FixLCSSALoop->getParentLoop(); + assert(FixLCSSALoop && "Should be a loop!"); + formLCSSARecursively(*FixLCSSALoop, DT, &LI, &SE); } } } -- cgit v1.2.3