[llvm] [SimplifyCFG][NFC] Improve compile time for TryToSimplifyUncondBranchFromEmptyBlock optimization. (PR #110715)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 7 12:00:39 PDT 2024


================
@@ -1042,7 +1043,8 @@ CanRedirectPredsOfEmptyBBToSucc(BasicBlock *BB, BasicBlock *Succ,
 
   // Get the single common predecessor of both BB and Succ. Return false
   // when there are more than one common predecessors.
-  for (BasicBlock *SuccPred : SuccPreds) {
+  for (BasicBlock *SuccPred : predecessors(Succ)) {
+    SuccPredsOut.insert(SuccPred);
----------------
nikic wrote:

Which part is important to short-circuit in your case? Is it the checks above or the check in this loop?

https://github.com/llvm/llvm-project/pull/110715


More information about the llvm-commits mailing list