diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2021-07-26 23:28:33 +0300 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2021-07-26 23:29:55 +0300 |
commit | 1901c98dd81bded0b95b2a1c0de05d56c24e7408 (patch) | |
tree | a3ba63d6e95c0a033ce9ed6e9e34894d38524dc4 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | 08efc2e68d5f9fe522fe8d70d0bd5ddf45f78848 (diff) | |
download | llvm-1901c98dd81bded0b95b2a1c0de05d56c24e7408.zip llvm-1901c98dd81bded0b95b2a1c0de05d56c24e7408.tar.gz llvm-1901c98dd81bded0b95b2a1c0de05d56c24e7408.tar.bz2 |
[SimplifyCFG] SwitchToLookupTable(): don't increase ret count
The very next SimplifyCFG pass invocation will tail-merge these two ret's
anyways, there is not much point in creating more work for ourselves.
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index ddee6a0..b32047f 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -5926,7 +5926,6 @@ static bool SwitchToLookupTable(SwitchInst *SI, IRBuilder<> &Builder, Updates.push_back({DominatorTree::Delete, BB, SI->getDefaultDest()}); } - bool ReturnedEarly = false; for (PHINode *PHI : PHIs) { const ResultListTy &ResultList = ResultLists[PHI]; @@ -5938,15 +5937,6 @@ static bool SwitchToLookupTable(SwitchInst *SI, IRBuilder<> &Builder, Value *Result = Table.BuildLookup(TableIndex, Builder); - // If the result is used to return immediately from the function, we want to - // do that right here. - if (PHI->hasOneUse() && isa<ReturnInst>(*PHI->user_begin()) && - PHI->user_back() == CommonDest->getFirstNonPHIOrDbg()) { - Builder.CreateRet(Result); - ReturnedEarly = true; - break; - } - // Do a small peephole optimization: re-use the switch table compare if // possible. if (!TableHasHoles && HasDefaultResults && RangeCheckBranch) { @@ -5960,11 +5950,9 @@ static bool SwitchToLookupTable(SwitchInst *SI, IRBuilder<> &Builder, PHI->addIncoming(Result, LookupBB); } - if (!ReturnedEarly) { - Builder.CreateBr(CommonDest); - if (DTU) - Updates.push_back({DominatorTree::Insert, LookupBB, CommonDest}); - } + Builder.CreateBr(CommonDest); + if (DTU) + Updates.push_back({DominatorTree::Insert, LookupBB, CommonDest}); // Remove the switch. SmallPtrSet<BasicBlock *, 8> RemovedSuccessors; |