[llvm] [SimplifyCFG] Consider preds to switch in `simplifyDuplicateSwitchArms` (PR #118955)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 10 00:10:46 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) {
----------------
antoniofrighetto wrote:
Correct, this way we keep the time complexity constant. Happy to tune this differently if compile-time remains fine.
https://github.com/llvm/llvm-project/pull/118955
More information about the llvm-commits
mailing list