[llvm] a13b7df - [CodeGen] Use llvm::successors (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 24 22:12:07 PST 2024


Author: Kazu Hirata
Date: 2024-01-24T22:11:56-08:00
New Revision: a13b7df7f2d19f0798dbb6c1c7aeac8c84002338

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

LOG: [CodeGen] Use llvm::successors (NFC)

Added: 
    

Modified: 
    llvm/lib/CodeGen/CodeGenPrepare.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 8ee1f19e083e4e7..2d18eba235b0f69 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -972,10 +972,9 @@ bool CodeGenPrepare::isMergingEmptyBlockProfitable(BasicBlock *BB,
   // that leads to this block.
   // FIXME: Is this really needed? Is this a correctness issue?
   for (BasicBlock *Pred : predecessors(BB)) {
-    if (auto *CBI = dyn_cast<CallBrInst>((Pred)->getTerminator()))
-      for (unsigned i = 0, e = CBI->getNumSuccessors(); i != e; ++i)
-        if (DestBB == CBI->getSuccessor(i))
-          return false;
+    if (isa<CallBrInst>(Pred->getTerminator()) &&
+        llvm::is_contained(successors(Pred), DestBB))
+      return false;
   }
 
   // Try to skip merging if the unique predecessor of BB is terminated by a


        


More information about the llvm-commits mailing list