[llvm] bdd8c11 - [IR] Revert r2694 in BasicBlock::removePredecessor

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Mon May 18 11:18:53 PDT 2020


Author: Jay Foad
Date: 2020-05-18T19:13:06+01:00
New Revision: bdd8c111fc0d880eec57db860249f1707eed6982

URL: https://github.com/llvm/llvm-project/commit/bdd8c111fc0d880eec57db860249f1707eed6982
DIFF: https://github.com/llvm/llvm-project/commit/bdd8c111fc0d880eec57db860249f1707eed6982.diff

LOG: [IR] Revert r2694 in BasicBlock::removePredecessor

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.

Differential Revision: https://reviews.llvm.org/D80128

Added: 
    

Modified: 
    llvm/lib/IR/BasicBlock.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index 358362cf07e8..4baf36839c6e 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -334,25 +334,9 @@ void BasicBlock::removePredecessor(BasicBlock *Pred,
   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) {


        


More information about the llvm-commits mailing list