[PATCH] D80128: [IR] Revert r2694 in BasicBlock::removePredecessor

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 18 08:34:38 PDT 2020


foad created this revision.
foad added reviewers: lattner, stephenneuendorffer.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

r2694 fixed a bug where removePredecessor could create IR with a use not
dominated by its def in a self loop. But this could only happen in an
unreachable loop, and since that time the rules have been relaxed so
that defs don't have to dominate uses in unreachable code, so the fix is
unnecessary. The regression test added in r2691 still stands.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80128

Files:
  llvm/lib/IR/BasicBlock.cpp


Index: llvm/lib/IR/BasicBlock.cpp
===================================================================
--- llvm/lib/IR/BasicBlock.cpp
+++ llvm/lib/IR/BasicBlock.cpp
@@ -334,25 +334,9 @@
   if (!APN) return;   // Quick exit.
 
   // If there are exactly two predecessors, then we want to nuke the PHI nodes
-  // altogether.  However, we cannot do this, if this in this case:
-  //
-  //  Loop:
-  //    %x = phi [X, Loop]
-  //    %x2 = add %x, 1         ;; This would become %x2 = add %x2, 1
-  //    br Loop                 ;; %x2 does not dominate all uses
-  //
-  // This is because the PHI node input is actually taken from the predecessor
-  // basic block.  The only case this can happen is with a self loop, so we
-  // check for this case explicitly now.
-  //
+  // altogether.
   unsigned max_idx = APN->getNumIncomingValues();
   assert(max_idx != 0 && "PHI Node in block with 0 predecessors!?!?!");
-  if (max_idx == 2) {
-    BasicBlock *Other = APN->getIncomingBlock(APN->getIncomingBlock(0) == Pred);
-
-    // Disable PHI elimination!
-    if (this == Other) max_idx = 3;
-  }
 
   // <= Two predecessors BEFORE I remove one?
   if (max_idx <= 2 && !KeepOneInputPHIs) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80128.264632.patch
Type: text/x-patch
Size: 1187 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200518/d727387b/attachment.bin>


More information about the llvm-commits mailing list