diff options
author | Manman Ren <manman.ren@gmail.com> | 2014-02-07 00:38:56 +0000 |
---|---|---|
committer | Manman Ren <manman.ren@gmail.com> | 2014-02-07 00:38:56 +0000 |
commit | ee5625b3c16bb4f0bf73be256c2775246b9acbbb (patch) | |
tree | 21b9c7674114d2bf8f5dcd45b17a8e47cf454002 /lib/CodeGen/IfConversion.cpp | |
parent | 1f65cfad962a2f0c27b2dcc2324a76c427ba7e2b (diff) | |
download | llvm-ee5625b3c16bb4f0bf73be256c2775246b9acbbb.tar.gz llvm-ee5625b3c16bb4f0bf73be256c2775246b9acbbb.tar.bz2 llvm-ee5625b3c16bb4f0bf73be256c2775246b9acbbb.tar.xz |
PGO branch weight: fix PR18752.
Fix a bug triggered in IfConverterTriangle when CvtBB has multiple predecessors
by getting the weights before removing a successor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200958 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/IfConversion.cpp')
-rw-r--r-- | lib/CodeGen/IfConversion.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/CodeGen/IfConversion.cpp b/lib/CodeGen/IfConversion.cpp index f0e8c4775c..b664b3b191 100644 --- a/lib/CodeGen/IfConversion.cpp +++ b/lib/CodeGen/IfConversion.cpp @@ -1180,12 +1180,14 @@ bool IfConverter::IfConvertTriangle(BBInfo &BBI, IfcvtKind Kind) { DontKill.clear(); bool HasEarlyExit = CvtBBI->FalseBB != NULL; - uint64_t CvtNext = 0, CvtFalse = 0, SumWeight = 0; + uint64_t CvtNext = 0, CvtFalse = 0, BBNext = 0, BBCvt = 0, SumWeight = 0; uint32_t WeightScale = 0; if (HasEarlyExit) { - // Get weights before modifying CvtBBI->BB. + // Get weights before modifying CvtBBI->BB and BBI.BB. CvtNext = MBPI->getEdgeWeight(CvtBBI->BB, NextBBI->BB); CvtFalse = MBPI->getEdgeWeight(CvtBBI->BB, CvtBBI->FalseBB); + BBNext = MBPI->getEdgeWeight(BBI.BB, NextBBI->BB); + BBCvt = MBPI->getEdgeWeight(BBI.BB, CvtBBI->BB); SumWeight = MBPI->getSumForBlock(CvtBBI->BB, WeightScale); } if (CvtBBI->BB->pred_size() > 1) { @@ -1222,9 +1224,6 @@ bool IfConverter::IfConvertTriangle(BBInfo &BBI, IfcvtKind Kind) { // New_Weight(BBI.BB, CvtBBI->FalseBB) = // Weight(BBI.BB, CvtBBI->BB) * Weight(CvtBBI->BB, CvtBBI->FalseBB) - uint64_t BBNext = MBPI->getEdgeWeight(BBI.BB, NextBBI->BB); - uint64_t BBCvt = MBPI->getEdgeWeight(BBI.BB, CvtBBI->BB); - uint64_t NewNext = BBNext * SumWeight + (BBCvt * CvtNext) / WeightScale; uint64_t NewFalse = (BBCvt * CvtFalse) / WeightScale; // We need to scale down all weights of BBI.BB to fit uint32_t. |