diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2016-05-09 17:31:55 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2016-05-09 17:31:55 +0000 |
| commit | c7b91e65d8960da9e9fb6a3d044f7da71d5879fa (patch) | |
| tree | f683b451658c8243ab494eb9ae7b646ba9da9ecd /llvm/lib/CodeGen/CodeGenPrepare.cpp | |
| parent | b5935bfd7dda5ce37f57f3f1902eb6855d948738 (diff) | |
| download | bcm5719-llvm-c7b91e65d8960da9e9fb6a3d044f7da71d5879fa.tar.gz bcm5719-llvm-c7b91e65d8960da9e9fb6a3d044f7da71d5879fa.zip | |
[CGP] avoid crashing from weightlessness
It's possible that we have branch weights with 0 values.
In that case, don't try to create an impossible BranchProbability.
llvm-svn: 268935
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index b5ffbeb3dec..56a1639c8e9 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -4559,9 +4559,11 @@ static bool isFormingBranchFromSelectProfitable(const TargetTransformInfo *TTI, if (SI->extractProfMetadata(TrueWeight, FalseWeight)) { uint64_t Max = std::max(TrueWeight, FalseWeight); uint64_t Sum = TrueWeight + FalseWeight; - auto Probability = BranchProbability::getBranchProbability(Max, Sum); - if (Probability > TLI->getPredictableBranchThreshold()) - return true; + if (Sum != 0) { + auto Probability = BranchProbability::getBranchProbability(Max, Sum); + if (Probability > TLI->getPredictableBranchThreshold()) + return true; + } } CmpInst *Cmp = dyn_cast<CmpInst>(SI->getCondition()); |

