[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:
I think this simplified to `ResultTypes[PHI] = Value->getType()`? You could also put it in the Inserted branch.
https://github.com/llvm/llvm-project/pull/155602
More information about the llvm-commits
mailing list