[PATCH] D21665: [LoopSimplify] Update LCSSA after separating nested loops.

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 27 13:27:50 PDT 2016


chandlerc added inline comments.

================
Comment at: lib/Transforms/Utils/LoopSimplify.cpp:343-345
@@ +342,5 @@
+  if (PreserveLCSSA) {
+    // Fix LCSSA form for L. Some values, which previously were only used inside
+    // L, can now be used in NewOuter loop. We need to insert phi-nodes for them
+    // in corresponding exit blocks.
+    SmallVector<BasicBlock *, 8> ExitBlocks;
----------------
Is it possible to track these when putting the instructions into this set? Maybe its just not worth it because its just the PHI nodes...

================
Comment at: lib/Transforms/Utils/LoopSimplify.cpp:346
@@ +345,3 @@
+    // in corresponding exit blocks.
+    SmallVector<BasicBlock *, 8> ExitBlocks;
+    L->getExitBlocks(ExitBlocks);
----------------
8? That seems like lots? Maybe not though

================
Comment at: lib/Transforms/Utils/LoopSimplify.cpp:360-365
@@ +359,8 @@
+        BasicBlock *IncomingBB = PN->getIncomingBlock(i);
+        for (BasicBlock *ExitBB : ExitBlocks) {
+          if (!DT->dominates(ExitBB, IncomingBB))
+            continue;
+
+          // We've found the exit block where we need to insert the phi-node.
+          // Create and start using it instead of previous def.
+          PHINode *NewPN = PHINode::Create(
----------------
It's a bit odd to use this linear search for a unique dominating exit block... I wonder, is there some implicit guarantee that makes it make more sense? Do we instead want to perhaps build up a map from incoming BB of the outer PHI to dominating exit BB?


http://reviews.llvm.org/D21665





More information about the llvm-commits mailing list