[llvm] [SimplifyCFG] Consider preds to switch in `simplifyDuplicateSwitchArms` (PR #118955)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 6 07:23:05 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) {
----------------
dtcxzyw wrote:
It is used to avoid `O(N^2)` lookup. We may choose a larger threshold if the compile-time impact is negligible.
https://github.com/llvm/llvm-project/pull/118955
More information about the llvm-commits
mailing list