diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2021-07-26 02:57:19 +0300 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2021-07-26 02:57:19 +0300 |
commit | c2dacb1cd3cc35213bb278f0746ef42a05e68e70 (patch) | |
tree | 257125ac4acc8ba525eb92a2c246160c6b549673 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | 59a5964e033c92f3b4866429552f20979c998e56 (diff) | |
download | llvm-c2dacb1cd3cc35213bb278f0746ef42a05e68e70.zip llvm-c2dacb1cd3cc35213bb278f0746ef42a05e68e70.tar.gz llvm-c2dacb1cd3cc35213bb278f0746ef42a05e68e70.tar.bz2 |
[SimplifyCFG] Fold branch to common dest: if branch is unpredictable, prefer to speculate
This is consistent with the two other usages of prof md in this pass.
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 7a88e1c..452db31 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -3054,7 +3054,8 @@ shouldFoldCondBranchesToCommonDestination(BranchInst *BI, BranchInst *PBI, // predecessor branch is predictable, we may not want to merge them. uint64_t PTWeight, PFWeight; BranchProbability PBITrueProb, Likely; - if (TTI && PBI->extractProfMetadata(PTWeight, PFWeight) && + if (TTI && !PBI->getMetadata(LLVMContext::MD_unpredictable) && + PBI->extractProfMetadata(PTWeight, PFWeight) && (PTWeight + PFWeight) != 0) { PBITrueProb = BranchProbability::getBranchProbability(PTWeight, PTWeight + PFWeight); |