mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-21 08:17:40 +00:00
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
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user