[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
       
    Tue Oct 21 14:02:53 PDT 2025
    
    
  
================
@@ -372,20 +374,19 @@ bool SwitchCG::SwitchLowering::buildBitTests(CaseClusterVector &Clusters,
   if (First == Last)
     return false;
 
-  BitVector Dests(FuncInfo.MF->getNumBlockIDs());
-  unsigned NumCmps = 0;
+  DenseMap<const BasicBlock *, unsigned int> DestMap;
   for (int64_t I = First; I <= Last; ++I) {
     assert(Clusters[I].Kind == CC_Range);
-    Dests.set(Clusters[I].MBB->getNumber());
-    NumCmps += (Clusters[I].Low == Clusters[I].High) ? 1 : 2;
+    unsigned NumCmp = (Clusters[I].Low == Clusters[I].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