[llvm] [NFC] SimplifyCFG: Detect switch replacement earlier in `switchToLookup` (PR #155602)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 28 06:02:17 PDT 2025


================
@@ -6955,31 +6964,25 @@ static bool switchToLookupTable(SwitchInst *SI, IRBuilder<> &Builder,
                         Results, DL, TTI))
       return false;
 
-    // Append the result from this case to the list for each phi.
+    // Append the result  and result types from this case to the list for each
+    // phi.
     for (const auto &I : Results) {
       PHINode *PHI = I.first;
       Constant *Value = I.second;
       auto [It, Inserted] = ResultLists.try_emplace(PHI);
       if (Inserted)
         PHIs.push_back(PHI);
       It->second.push_back(std::make_pair(CaseVal, Value));
+      ResultTypes[PHI] = ResultLists[PHI][0].second->getType();
----------------
nikic wrote:

Or even `PHI->getType()`? TBH I'm confused by the purpose of ResultTypes. Do we ever even use the phi portion of that, rather than only working on the types?

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


More information about the llvm-commits mailing list