[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


================
@@ -1182,6 +1184,10 @@ bool llvm::TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB,
   if ((!BBKillable && !BBPhisMergeable) || introduceTooManyPhiEntries(BB, Succ))
     return false;
 
+  // SuccPreds may not have been fully filled by CanRedirectPredsOfEmptyBBToSucc
+  // so finish it here.
+  SuccPreds.insert(pred_begin(Succ), pred_end(Succ));
----------------
nikic wrote:

Given that you iterate over all predecessors again here anyway, I think it would be cleaner to just only construct SuccPreds here and not try to partially cache it in CanRedirectPredsOfEmptyBBToSucc. It doesn't seem like we're actually saying any work, but it makes the API contract rather confusing.

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


More information about the llvm-commits mailing list