Lines Matching refs:BBI
171 BBInfo &BBI; member
181 : BBI(b), Kind(k), NumDups(d), NumDups2(d2), NeedSubsumption(s), in IfcvtToken()
226 bool reverseBranchCondition(BBInfo &BBI) const;
244 void AnalyzeBranches(BBInfo &BBI);
245 void ScanInstructions(BBInfo &BBI,
255 bool FeasibilityAnalysis(BBInfo &BBI, SmallVectorImpl<MachineOperand> &Pred,
261 bool IfConvertSimple(BBInfo &BBI, IfcvtKind Kind);
262 bool IfConvertTriangle(BBInfo &BBI, IfcvtKind Kind);
263 bool IfConvertDiamondCommon(BBInfo &BBI, BBInfo &TrueBBI, BBInfo &FalseBBI,
267 bool IfConvertDiamond(BBInfo &BBI, IfcvtKind Kind,
270 bool IfConvertForkedDiamond(BBInfo &BBI, IfcvtKind Kind,
273 void PredicateBlock(BBInfo &BBI,
399 bool blockAlwaysFallThrough(BBInfo &BBI) const { in blockAlwaysFallThrough()
400 return BBI.IsBrAnalyzable && BBI.TrueBB == nullptr; in blockAlwaysFallThrough()
421 return C1->BBI.BB->getNumber() < C2->BBI.BB->getNumber(); in IfcvtTokenCmp()
490 BBInfo &BBI = Token->BBI; in INITIALIZE_PASS_DEPENDENCY() local
497 if (BBI.IsDone) in INITIALIZE_PASS_DEPENDENCY()
498 BBI.IsEnqueued = false; in INITIALIZE_PASS_DEPENDENCY()
499 if (!BBI.IsEnqueued) in INITIALIZE_PASS_DEPENDENCY()
502 BBI.IsEnqueued = false; in INITIALIZE_PASS_DEPENDENCY()
513 << "): " << printMBBReference(*BBI.BB) << " (" in INITIALIZE_PASS_DEPENDENCY()
514 << ((Kind == ICSimpleFalse) ? BBI.FalseBB->getNumber() in INITIALIZE_PASS_DEPENDENCY()
515 : BBI.TrueBB->getNumber()) in INITIALIZE_PASS_DEPENDENCY()
517 RetVal = IfConvertSimple(BBI, Kind); in INITIALIZE_PASS_DEPENDENCY()
539 LLVM_DEBUG(dbgs() << "): " << printMBBReference(*BBI.BB) in INITIALIZE_PASS_DEPENDENCY()
540 << " (T:" << BBI.TrueBB->getNumber() in INITIALIZE_PASS_DEPENDENCY()
541 << ",F:" << BBI.FalseBB->getNumber() << ") "); in INITIALIZE_PASS_DEPENDENCY()
542 RetVal = IfConvertTriangle(BBI, Kind); in INITIALIZE_PASS_DEPENDENCY()
556 LLVM_DEBUG(dbgs() << "Ifcvt (Diamond): " << printMBBReference(*BBI.BB) in INITIALIZE_PASS_DEPENDENCY()
557 << " (T:" << BBI.TrueBB->getNumber() in INITIALIZE_PASS_DEPENDENCY()
558 << ",F:" << BBI.FalseBB->getNumber() << ") "); in INITIALIZE_PASS_DEPENDENCY()
559 RetVal = IfConvertDiamond(BBI, Kind, NumDups, NumDups2, in INITIALIZE_PASS_DEPENDENCY()
568 << printMBBReference(*BBI.BB) in INITIALIZE_PASS_DEPENDENCY()
569 << " (T:" << BBI.TrueBB->getNumber() in INITIALIZE_PASS_DEPENDENCY()
570 << ",F:" << BBI.FalseBB->getNumber() << ") "); in INITIALIZE_PASS_DEPENDENCY()
571 RetVal = IfConvertForkedDiamond(BBI, Kind, NumDups, NumDups2, in INITIALIZE_PASS_DEPENDENCY()
580 recomputeLivenessFlags(*BBI.BB); in INITIALIZE_PASS_DEPENDENCY()
619 bool IfConverter::reverseBranchCondition(BBInfo &BBI) const { in reverseBranchCondition()
621 if (!TII->reverseBranchCondition(BBI.BrCond)) { in reverseBranchCondition()
622 TII->removeBranch(*BBI.BB); in reverseBranchCondition()
623 TII->insertBranch(*BBI.BB, BBI.FalseBB, BBI.TrueBB, BBI.BrCond, dl); in reverseBranchCondition()
624 std::swap(BBI.TrueBB, BBI.FalseBB); in reverseBranchCondition()
1019 void IfConverter::AnalyzeBranches(BBInfo &BBI) { in AnalyzeBranches() argument
1020 if (BBI.IsDone) in AnalyzeBranches()
1023 BBI.TrueBB = BBI.FalseBB = nullptr; in AnalyzeBranches()
1024 BBI.BrCond.clear(); in AnalyzeBranches()
1025 BBI.IsBrAnalyzable = in AnalyzeBranches()
1026 !TII->analyzeBranch(*BBI.BB, BBI.TrueBB, BBI.FalseBB, BBI.BrCond); in AnalyzeBranches()
1027 if (!BBI.IsBrAnalyzable) { in AnalyzeBranches()
1028 BBI.TrueBB = nullptr; in AnalyzeBranches()
1029 BBI.FalseBB = nullptr; in AnalyzeBranches()
1030 BBI.BrCond.clear(); in AnalyzeBranches()
1033 SmallVector<MachineOperand, 4> RevCond(BBI.BrCond.begin(), BBI.BrCond.end()); in AnalyzeBranches()
1034 BBI.IsBrReversible = (RevCond.size() == 0) || in AnalyzeBranches()
1036 BBI.HasFallThrough = BBI.IsBrAnalyzable && BBI.FalseBB == nullptr; in AnalyzeBranches()
1038 if (BBI.BrCond.size()) { in AnalyzeBranches()
1041 if (!BBI.FalseBB) in AnalyzeBranches()
1042 BBI.FalseBB = findFalseBlock(BBI.BB, BBI.TrueBB); in AnalyzeBranches()
1043 if (!BBI.FalseBB) { in AnalyzeBranches()
1045 BBI.IsUnpredicable = true; in AnalyzeBranches()
1055 void IfConverter::ScanInstructions(BBInfo &BBI, in ScanInstructions() argument
1059 if (BBI.IsDone || BBI.IsUnpredicable) in ScanInstructions()
1062 bool AlreadyPredicated = !BBI.Predicate.empty(); in ScanInstructions()
1064 BBI.NonPredSize = 0; in ScanInstructions()
1065 BBI.ExtraCost = 0; in ScanInstructions()
1066 BBI.ExtraCost2 = 0; in ScanInstructions()
1067 BBI.ClobbersPred = false; in ScanInstructions()
1103 BBI.CannotBeCopied = true; in ScanInstructions()
1106 bool isCondBr = BBI.IsBrAnalyzable && MI.isConditionalBranch(); in ScanInstructions()
1109 BBI.IsUnpredicable = true; in ScanInstructions()
1118 BBI.NonPredSize++; in ScanInstructions()
1122 BBI.ExtraCost += NumCycles-1; in ScanInstructions()
1123 BBI.ExtraCost2 += ExtraPredCost; in ScanInstructions()
1128 BBI.IsUnpredicable = true; in ScanInstructions()
1132 if (BBI.ClobbersPred && !isPredicated) { in ScanInstructions()
1137 BBI.IsUnpredicable = true; in ScanInstructions()
1145 BBI.ClobbersPred = true; in ScanInstructions()
1148 BBI.IsUnpredicable = true; in ScanInstructions()
1163 bool IfConverter::FeasibilityAnalysis(BBInfo &BBI, in FeasibilityAnalysis() argument
1171 if (BBI.IsDone || (BBI.IsUnpredicable && !hasCommonTail)) in FeasibilityAnalysis()
1177 if (BBI.Predicate.size() && !BBI.IsBrAnalyzable) in FeasibilityAnalysis()
1182 if (BBI.Predicate.size() && !TII->SubsumesPredicate(Pred, BBI.Predicate)) in FeasibilityAnalysis()
1185 if (!hasCommonTail && BBI.BrCond.size()) { in FeasibilityAnalysis()
1191 SmallVector<MachineOperand, 4> Cond(BBI.BrCond.begin(), BBI.BrCond.end()); in FeasibilityAnalysis()
1222 BBInfo &BBI = BBAnalysis[BB->getNumber()]; in AnalyzeBlock() local
1225 if (BBI.IsAnalyzed || BBI.IsBeingAnalyzed) { in AnalyzeBlock()
1230 BBI.BB = BB; in AnalyzeBlock()
1231 BBI.IsBeingAnalyzed = true; in AnalyzeBlock()
1233 AnalyzeBranches(BBI); in AnalyzeBlock()
1234 MachineBasicBlock::iterator Begin = BBI.BB->begin(); in AnalyzeBlock()
1235 MachineBasicBlock::iterator End = BBI.BB->end(); in AnalyzeBlock()
1236 ScanInstructions(BBI, Begin, End); in AnalyzeBlock()
1240 if (!BBI.IsBrAnalyzable || BBI.BrCond.empty() || BBI.IsDone) { in AnalyzeBlock()
1241 BBI.IsBeingAnalyzed = false; in AnalyzeBlock()
1242 BBI.IsAnalyzed = true; in AnalyzeBlock()
1248 if (BBI.TrueBB == BB || BBI.FalseBB == BB) { in AnalyzeBlock()
1249 BBI.IsBeingAnalyzed = false; in AnalyzeBlock()
1250 BBI.IsAnalyzed = true; in AnalyzeBlock()
1256 if (!BBI.FalseBB) { in AnalyzeBlock()
1257 BBI.IsBeingAnalyzed = false; in AnalyzeBlock()
1258 BBI.IsAnalyzed = true; in AnalyzeBlock()
1265 BBStack.push_back(*BBI.FalseBB); in AnalyzeBlock()
1266 BBStack.push_back(*BBI.TrueBB); in AnalyzeBlock()
1270 BBInfo &TrueBBI = BBAnalysis[BBI.TrueBB->getNumber()]; in AnalyzeBlock()
1271 BBInfo &FalseBBI = BBAnalysis[BBI.FalseBB->getNumber()]; in AnalyzeBlock()
1274 BBI.IsBeingAnalyzed = false; in AnalyzeBlock()
1275 BBI.IsAnalyzed = true; in AnalyzeBlock()
1281 RevCond(BBI.BrCond.begin(), BBI.BrCond.end()); in AnalyzeBlock()
1297 bool TrueFeasible = FeasibilityAnalysis(TrueBBI, BBI.BrCond, in AnalyzeBlock()
1318 BBI, ICDiamond, TNeedSub | FNeedSub, Dups, Dups2, in AnalyzeBlock()
1336 BBI, ICForkedDiamond, TNeedSub | FNeedSub, Dups, Dups2, in AnalyzeBlock()
1346 FeasibilityAnalysis(TrueBBI, BBI.BrCond, true)) { in AnalyzeBlock()
1355 std::make_unique<IfcvtToken>(BBI, ICTriangle, TNeedSub, Dups)); in AnalyzeBlock()
1362 FeasibilityAnalysis(TrueBBI, BBI.BrCond, true, true)) { in AnalyzeBlock()
1364 std::make_unique<IfcvtToken>(BBI, ICTriangleRev, TNeedSub, Dups)); in AnalyzeBlock()
1371 FeasibilityAnalysis(TrueBBI, BBI.BrCond)) { in AnalyzeBlock()
1380 std::make_unique<IfcvtToken>(BBI, ICSimple, TNeedSub, Dups)); in AnalyzeBlock()
1392 Tokens.push_back(std::make_unique<IfcvtToken>(BBI, ICTriangleFalse, in AnalyzeBlock()
1404 std::make_unique<IfcvtToken>(BBI, ICTriangleFRev, FNeedSub, Dups)); in AnalyzeBlock()
1414 std::make_unique<IfcvtToken>(BBI, ICSimpleFalse, FNeedSub, Dups)); in AnalyzeBlock()
1419 BBI.IsEnqueued = Enqueued; in AnalyzeBlock()
1420 BBI.IsBeingAnalyzed = false; in AnalyzeBlock()
1421 BBI.IsAnalyzed = true; in AnalyzeBlock()
1519 bool IfConverter::IfConvertSimple(BBInfo &BBI, IfcvtKind Kind) { in IfConvertSimple() argument
1520 BBInfo &TrueBBI = BBAnalysis[BBI.TrueBB->getNumber()]; in IfConvertSimple()
1521 BBInfo &FalseBBI = BBAnalysis[BBI.FalseBB->getNumber()]; in IfConvertSimple()
1525 SmallVector<MachineOperand, 4> Cond(BBI.BrCond.begin(), BBI.BrCond.end()); in IfConvertSimple()
1534 BBI.IsAnalyzed = false; in IfConvertSimple()
1558 BBI.NonPredSize -= TII->removeBranch(*BBI.BB); in IfConvertSimple()
1563 CopyAndPredicateBlock(BBI, *CvtBBI, Cond); in IfConvertSimple()
1566 BBI.BB->removeSuccessor(&CvtMBB, true); in IfConvertSimple()
1573 MergeBlocks(BBI, *CvtBBI); in IfConvertSimple()
1577 if (!canFallThroughTo(*BBI.BB, NextMBB)) { in IfConvertSimple()
1578 InsertUncondBranch(*BBI.BB, NextMBB, TII); in IfConvertSimple()
1579 BBI.HasFallThrough = false; in IfConvertSimple()
1595 BBI.IsDone = true; in IfConvertSimple()
1596 InvalidatePreds(*BBI.BB); in IfConvertSimple()
1604 bool IfConverter::IfConvertTriangle(BBInfo &BBI, IfcvtKind Kind) { in IfConvertTriangle() argument
1605 BBInfo &TrueBBI = BBAnalysis[BBI.TrueBB->getNumber()]; in IfConvertTriangle()
1606 BBInfo &FalseBBI = BBAnalysis[BBI.FalseBB->getNumber()]; in IfConvertTriangle()
1611 SmallVector<MachineOperand, 4> Cond(BBI.BrCond.begin(), BBI.BrCond.end()); in IfConvertTriangle()
1620 BBI.IsAnalyzed = false; in IfConvertTriangle()
1638 if (PBB == BBI.BB) in IfConvertTriangle()
1664 BBNext = MBPI->getEdgeProbability(BBI.BB, &NextMBB); in IfConvertTriangle()
1665 BBCvt = MBPI->getEdgeProbability(BBI.BB, &CvtMBB); in IfConvertTriangle()
1670 BBI.NonPredSize -= TII->removeBranch(*BBI.BB); in IfConvertTriangle()
1675 CopyAndPredicateBlock(BBI, *CvtBBI, Cond, true); in IfConvertTriangle()
1682 MergeBlocks(BBI, *CvtBBI, false); in IfConvertTriangle()
1686 BBI.BB->removeSuccessor(&CvtMBB, true); in IfConvertTriangle()
1701 auto NewTrueBB = getNextBlock(*BBI.BB); in IfConvertTriangle()
1703 auto NewTrueBBIter = find(BBI.BB->successors(), NewTrueBB); in IfConvertTriangle()
1704 if (NewTrueBBIter != BBI.BB->succ_end()) in IfConvertTriangle()
1705 BBI.BB->setSuccProbability(NewTrueBBIter, NewNext); in IfConvertTriangle()
1708 TII->insertBranch(*BBI.BB, CvtBBI->FalseBB, nullptr, RevCond, dl); in IfConvertTriangle()
1709 BBI.BB->addSuccessor(CvtBBI->FalseBB, NewFalse); in IfConvertTriangle()
1716 bool isFallThrough = canFallThroughTo(*BBI.BB, NextMBB); in IfConvertTriangle()
1724 MergeBlocks(BBI, *NextBBI); in IfConvertTriangle()
1727 InsertUncondBranch(*BBI.BB, NextMBB, TII); in IfConvertTriangle()
1728 BBI.HasFallThrough = false; in IfConvertTriangle()
1737 BBI.IsDone = true; in IfConvertTriangle()
1738 InvalidatePreds(*BBI.BB); in IfConvertTriangle()
1759 BBInfo &BBI, BBInfo &TrueBBI, BBInfo &FalseBBI, in IfConvertDiamondCommon() argument
1767 BBI.IsAnalyzed = false; in IfConvertDiamondCommon()
1782 SmallVector<MachineOperand, 4> RevCond(BBI.BrCond.begin(), BBI.BrCond.end()); in IfConvertDiamondCommon()
1785 SmallVector<MachineOperand, 4> *Cond1 = &BBI.BrCond; in IfConvertDiamondCommon()
1803 BBI.NonPredSize -= TII->removeBranch(*BBI.BB); in IfConvertDiamondCommon()
1856 BBI.BB->splice(BBI.BB->end(), &MBB1, MBB1.begin(), DI1); in IfConvertDiamondCommon()
1985 MergeBlocks(BBI, *BBI1, MergeAddEdges); in IfConvertDiamondCommon()
1986 MergeBlocks(BBI, *BBI2, MergeAddEdges); in IfConvertDiamondCommon()
1993 BBInfo &BBI, IfcvtKind Kind, in IfConvertForkedDiamond() argument
1996 BBInfo &TrueBBI = BBAnalysis[BBI.TrueBB->getNumber()]; in IfConvertForkedDiamond()
1997 BBInfo &FalseBBI = BBAnalysis[BBI.FalseBB->getNumber()]; in IfConvertForkedDiamond()
2008 BBI, TrueBBI, FalseBBI, in IfConvertForkedDiamond()
2016 TII->insertBranch(*BBI.BB, TrueBBI.TrueBB, TrueBBI.FalseBB, in IfConvertForkedDiamond()
2020 BBI.IsDone = TrueBBI.IsDone = FalseBBI.IsDone = true; in IfConvertForkedDiamond()
2021 InvalidatePreds(*BBI.BB); in IfConvertForkedDiamond()
2028 bool IfConverter::IfConvertDiamond(BBInfo &BBI, IfcvtKind Kind, in IfConvertDiamond() argument
2031 BBInfo &TrueBBI = BBAnalysis[BBI.TrueBB->getNumber()]; in IfConvertDiamond()
2032 BBInfo &FalseBBI = BBAnalysis[BBI.FalseBB->getNumber()]; in IfConvertDiamond()
2043 BBI, TrueBBI, FalseBBI, in IfConvertDiamond()
2057 BBI.BB->removeSuccessor(TrueBBI.BB); in IfConvertDiamond()
2058 BBI.BB->removeSuccessor(FalseBBI.BB, true); in IfConvertDiamond()
2066 MachineBasicBlock::const_iterator TI = BBI.BB->getFirstTerminator(); in IfConvertDiamond()
2067 if (TI != BBI.BB->end() && TII->isPredicated(*TI)) in IfConvertDiamond()
2080 MergeBlocks(BBI, TailBBI); in IfConvertDiamond()
2083 BBI.BB->addSuccessor(TailBB, BranchProbability::getOne()); in IfConvertDiamond()
2084 InsertUncondBranch(*BBI.BB, *TailBB, TII); in IfConvertDiamond()
2085 BBI.HasFallThrough = false; in IfConvertDiamond()
2090 BBI.IsDone = TrueBBI.IsDone = FalseBBI.IsDone = true; in IfConvertDiamond()
2091 InvalidatePreds(*BBI.BB); in IfConvertDiamond()
2118 void IfConverter::PredicateBlock(BBInfo &BBI, in PredicateBlock() argument
2124 for (MachineInstr &I : make_range(BBI.BB->begin(), E)) { in PredicateBlock()
2149 BBI.Predicate.append(Cond.begin(), Cond.end()); in PredicateBlock()
2151 BBI.IsAnalyzed = false; in PredicateBlock()
2152 BBI.NonPredSize = 0; in PredicateBlock()