diff options
author | DianQK <dianqk@dianqk.net> | 2024-06-27 05:49:33 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-27 05:49:33 +0800 |
commit | 0c56fd0a29ffb0425ca2ee2a4ff8f380880fdbfa (patch) | |
tree | b079d0d94f6c692453a790b7db42f84150abda08 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | 02b57dedb73134bc81f09e2ff3c56e286091ba13 (diff) | |
download | llvm-0c56fd0a29ffb0425ca2ee2a4ff8f380880fdbfa.zip llvm-0c56fd0a29ffb0425ca2ee2a4ff8f380880fdbfa.tar.gz llvm-0c56fd0a29ffb0425ca2ee2a4ff8f380880fdbfa.tar.bz2 |
[SimplifyCFG] Forward indirect switch condition value if it can help fold the PHI (#95932)
Fixes #95919.
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 4e2dc7f..c52c4dc 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -5818,7 +5818,8 @@ static bool ForwardSwitchConditionToPHI(SwitchInst *SI) { for (auto &ForwardingNode : ForwardingNodes) { PHINode *Phi = ForwardingNode.first; SmallVectorImpl<int> &Indexes = ForwardingNode.second; - if (Indexes.size() < 2) + // Check if it helps to fold PHI. + if (Indexes.size() < 2 && !llvm::is_contained(Phi->incoming_values(), SI->getCondition())) continue; for (int Index : Indexes) |