[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:36 PDT 2025


================
@@ -594,12 +594,13 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
 
     // Check if suitable for a bit test
     if (N <= DL.getIndexSizeInBits(0u)) {
-      SmallPtrSet<const BasicBlock *, 4> Dests;
-      for (auto I : SI.cases())
-        Dests.insert(I.getCaseSuccessor());
+      DenseMap<const BasicBlock *, unsigned int> DestMap;
+      for (auto I : SI.cases()) {
+        const BasicBlock *BB = I.getCaseSuccessor();
+        DestMap[BB] = DestMap.count(BB) ? (DestMap.count(BB) + 1) : 1;
----------------
efriedma-quic wrote:

```suggestion
        ++DestMap[BB]
```

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


More information about the llvm-commits mailing list