[llvm] [SimplifyCFG] Consider preds to switch in `simplifyDuplicateSwitchArms` (PR #118955)

Michael Maitland via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 6 07:06:30 PST 2024


================
@@ -7575,8 +7573,10 @@ bool SimplifyCFGOpt::simplifyDuplicateSwitchArms(SwitchInst *SI,
       continue;
 
     // FIXME: This case needs some extra care because the terminators other than
-    // SI need to be updated.
-    if (BB->hasNPredecessorsOrMore(2))
+    // SI need to be updated. For now, consider only backedges to the SI.
+    if (pred_size(BB) > 4 || any_of(predecessors(BB), [&](BasicBlock *Pred) {
----------------
michaelmaitland wrote:

What is special about having >= 4 predecessors? 

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


More information about the llvm-commits mailing list