[llvm] [PPC] Set minimum of largest number of comparisons to use bit test for switch lowering (PR #155910)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 22 13:52:35 PDT 2025
================
@@ -206,12 +206,16 @@ bool SwitchCG::SwitchLowering::buildJumpTable(const CaseClusterVector &Clusters,
for (unsigned I = First; I <= Last; ++I)
JTProbs[Clusters[I].MBB] = BranchProbability::getZero();
+ DenseMap<const BasicBlock *, unsigned int> DestMap;
for (unsigned I = First; I <= Last; ++I) {
assert(Clusters[I].Kind == CC_Range);
Prob += Clusters[I].Prob;
const APInt &Low = Clusters[I].Low->getValue();
const APInt &High = Clusters[I].High->getValue();
- NumCmps += (Low == High) ? 1 : 2;
+ unsigned int NumCmp = (Low == High) ? 1 : 2;
+ const BasicBlock *BB = Clusters[I].MBB->getBasicBlock();
+ DestMap[BB] = DestMap.count(BB) ? (DestMap[BB] + NumCmp) : NumCmp;
----------------
efriedma-quic wrote:
```suggestion
DestMap[BB] += NumCmp;
```
https://github.com/llvm/llvm-project/pull/155910
More information about the llvm-commits
mailing list