Lines Matching refs:BBI
149 BBInfo &BBI; member
155 : BBI(b), Kind(k), NeedSubsumption(s), NumDups(d), NumDups2(d2) {} in IfcvtToken()
198 bool ReverseBranchCondition(BBInfo &BBI);
206 void ScanInstructions(BBInfo &BBI);
209 bool FeasibilityAnalysis(BBInfo &BBI, SmallVectorImpl<MachineOperand> &Cond,
214 void RemoveExtraEdges(BBInfo &BBI);
215 bool IfConvertSimple(BBInfo &BBI, IfcvtKind Kind);
216 bool IfConvertTriangle(BBInfo &BBI, IfcvtKind Kind);
217 bool IfConvertDiamond(BBInfo &BBI, IfcvtKind Kind,
219 void PredicateBlock(BBInfo &BBI,
246 bool blockAlwaysFallThrough(BBInfo &BBI) const { in blockAlwaysFallThrough()
247 return BBI.IsBrAnalyzable && BBI.TrueBB == nullptr; in blockAlwaysFallThrough()
268 return C1->BBI.BB->getNumber() < C2->BBI.BB->getNumber(); in IfcvtTokenCmp()
334 BBInfo &BBI = Token->BBI; in INITIALIZE_PASS_DEPENDENCY() local
341 if (BBI.IsDone) in INITIALIZE_PASS_DEPENDENCY()
342 BBI.IsEnqueued = false; in INITIALIZE_PASS_DEPENDENCY()
343 if (!BBI.IsEnqueued) in INITIALIZE_PASS_DEPENDENCY()
346 BBI.IsEnqueued = false; in INITIALIZE_PASS_DEPENDENCY()
357 << "): BB#" << BBI.BB->getNumber() << " (" in INITIALIZE_PASS_DEPENDENCY()
359 ? BBI.FalseBB->getNumber() in INITIALIZE_PASS_DEPENDENCY()
360 : BBI.TrueBB->getNumber()) << ") "); in INITIALIZE_PASS_DEPENDENCY()
361 RetVal = IfConvertSimple(BBI, Kind); in INITIALIZE_PASS_DEPENDENCY()
384 DEBUG(dbgs() << "): BB#" << BBI.BB->getNumber() << " (T:" in INITIALIZE_PASS_DEPENDENCY()
385 << BBI.TrueBB->getNumber() << ",F:" in INITIALIZE_PASS_DEPENDENCY()
386 << BBI.FalseBB->getNumber() << ") "); in INITIALIZE_PASS_DEPENDENCY()
387 RetVal = IfConvertTriangle(BBI, Kind); in INITIALIZE_PASS_DEPENDENCY()
402 DEBUG(dbgs() << "Ifcvt (Diamond): BB#" << BBI.BB->getNumber() << " (T:" in INITIALIZE_PASS_DEPENDENCY()
403 << BBI.TrueBB->getNumber() << ",F:" in INITIALIZE_PASS_DEPENDENCY()
404 << BBI.FalseBB->getNumber() << ") "); in INITIALIZE_PASS_DEPENDENCY()
405 RetVal = IfConvertDiamond(BBI, Kind, NumDups, NumDups2); in INITIALIZE_PASS_DEPENDENCY()
453 bool IfConverter::ReverseBranchCondition(BBInfo &BBI) { in ReverseBranchCondition() argument
455 if (!TII->ReverseBranchCondition(BBI.BrCond)) { in ReverseBranchCondition()
456 TII->RemoveBranch(*BBI.BB); in ReverseBranchCondition()
457 TII->InsertBranch(*BBI.BB, BBI.FalseBB, BBI.TrueBB, BBI.BrCond, dl); in ReverseBranchCondition()
458 std::swap(BBI.TrueBB, BBI.FalseBB); in ReverseBranchCondition()
649 void IfConverter::ScanInstructions(BBInfo &BBI) { in ScanInstructions() argument
650 if (BBI.IsDone) in ScanInstructions()
653 bool AlreadyPredicated = !BBI.Predicate.empty(); in ScanInstructions()
655 BBI.TrueBB = BBI.FalseBB = nullptr; in ScanInstructions()
656 BBI.BrCond.clear(); in ScanInstructions()
657 BBI.IsBrAnalyzable = in ScanInstructions()
658 !TII->analyzeBranch(*BBI.BB, BBI.TrueBB, BBI.FalseBB, BBI.BrCond); in ScanInstructions()
659 BBI.HasFallThrough = BBI.IsBrAnalyzable && BBI.FalseBB == nullptr; in ScanInstructions()
661 if (BBI.BrCond.size()) { in ScanInstructions()
664 if (!BBI.FalseBB) in ScanInstructions()
665 BBI.FalseBB = findFalseBlock(BBI.BB, BBI.TrueBB); in ScanInstructions()
666 if (!BBI.FalseBB) { in ScanInstructions()
668 BBI.IsUnpredicable = true; in ScanInstructions()
674 BBI.NonPredSize = 0; in ScanInstructions()
675 BBI.ExtraCost = 0; in ScanInstructions()
676 BBI.ExtraCost2 = 0; in ScanInstructions()
677 BBI.ClobbersPred = false; in ScanInstructions()
678 for (auto &MI : *BBI.BB) { in ScanInstructions()
713 BBI.CannotBeCopied = true; in ScanInstructions()
716 bool isCondBr = BBI.IsBrAnalyzable && MI.isConditionalBranch(); in ScanInstructions()
723 BBI.NonPredSize++; in ScanInstructions()
727 BBI.ExtraCost += NumCycles-1; in ScanInstructions()
728 BBI.ExtraCost2 += ExtraPredCost; in ScanInstructions()
733 BBI.IsUnpredicable = true; in ScanInstructions()
737 if (BBI.ClobbersPred && !isPredicated) { in ScanInstructions()
742 BBI.IsUnpredicable = true; in ScanInstructions()
750 BBI.ClobbersPred = true; in ScanInstructions()
753 BBI.IsUnpredicable = true; in ScanInstructions()
761 bool IfConverter::FeasibilityAnalysis(BBInfo &BBI, in FeasibilityAnalysis() argument
765 if (BBI.IsDone || BBI.IsUnpredicable) in FeasibilityAnalysis()
771 if (BBI.Predicate.size() && !BBI.IsBrAnalyzable) in FeasibilityAnalysis()
776 if (BBI.Predicate.size() && !TII->SubsumesPredicate(Pred, BBI.Predicate)) in FeasibilityAnalysis()
779 if (BBI.BrCond.size()) { in FeasibilityAnalysis()
785 SmallVector<MachineOperand, 4> Cond(BBI.BrCond.begin(), BBI.BrCond.end()); in FeasibilityAnalysis()
817 BBInfo &BBI = BBAnalysis[BB->getNumber()]; in AnalyzeBlock() local
820 if (BBI.IsAnalyzed || BBI.IsBeingAnalyzed) { in AnalyzeBlock()
825 BBI.BB = BB; in AnalyzeBlock()
826 BBI.IsBeingAnalyzed = true; in AnalyzeBlock()
828 ScanInstructions(BBI); in AnalyzeBlock()
832 if (!BBI.IsBrAnalyzable || BBI.BrCond.empty() || BBI.IsDone) { in AnalyzeBlock()
833 BBI.IsBeingAnalyzed = false; in AnalyzeBlock()
834 BBI.IsAnalyzed = true; in AnalyzeBlock()
840 if (BBI.TrueBB == BB || BBI.FalseBB == BB) { in AnalyzeBlock()
841 BBI.IsBeingAnalyzed = false; in AnalyzeBlock()
842 BBI.IsAnalyzed = true; in AnalyzeBlock()
848 if (!BBI.FalseBB) { in AnalyzeBlock()
849 BBI.IsBeingAnalyzed = false; in AnalyzeBlock()
850 BBI.IsAnalyzed = true; in AnalyzeBlock()
857 BBStack.push_back(BBI.FalseBB); in AnalyzeBlock()
858 BBStack.push_back(BBI.TrueBB); in AnalyzeBlock()
862 BBInfo &TrueBBI = BBAnalysis[BBI.TrueBB->getNumber()]; in AnalyzeBlock()
863 BBInfo &FalseBBI = BBAnalysis[BBI.FalseBB->getNumber()]; in AnalyzeBlock()
866 BBI.IsBeingAnalyzed = false; in AnalyzeBlock()
867 BBI.IsAnalyzed = true; in AnalyzeBlock()
873 RevCond(BBI.BrCond.begin(), BBI.BrCond.end()); in AnalyzeBlock()
890 FeasibilityAnalysis(TrueBBI, BBI.BrCond) && in AnalyzeBlock()
901 BBI, ICDiamond, TNeedSub | FNeedSub, Dups, Dups2)); in AnalyzeBlock()
908 FeasibilityAnalysis(TrueBBI, BBI.BrCond, true)) { in AnalyzeBlock()
917 llvm::make_unique<IfcvtToken>(BBI, ICTriangle, TNeedSub, Dups)); in AnalyzeBlock()
924 FeasibilityAnalysis(TrueBBI, BBI.BrCond, true, true)) { in AnalyzeBlock()
926 llvm::make_unique<IfcvtToken>(BBI, ICTriangleRev, TNeedSub, Dups)); in AnalyzeBlock()
933 FeasibilityAnalysis(TrueBBI, BBI.BrCond)) { in AnalyzeBlock()
942 llvm::make_unique<IfcvtToken>(BBI, ICSimple, TNeedSub, Dups)); in AnalyzeBlock()
954 Tokens.push_back(llvm::make_unique<IfcvtToken>(BBI, ICTriangleFalse, in AnalyzeBlock()
966 llvm::make_unique<IfcvtToken>(BBI, ICTriangleFRev, FNeedSub, Dups)); in AnalyzeBlock()
976 llvm::make_unique<IfcvtToken>(BBI, ICSimpleFalse, FNeedSub, Dups)); in AnalyzeBlock()
981 BBI.IsEnqueued = Enqueued; in AnalyzeBlock()
982 BBI.IsBeingAnalyzed = false; in AnalyzeBlock()
983 BBI.IsAnalyzed = true; in AnalyzeBlock()
1041 void IfConverter::RemoveExtraEdges(BBInfo &BBI) { in RemoveExtraEdges() argument
1044 if (!TII->analyzeBranch(*BBI.BB, TBB, FBB, Cond)) in RemoveExtraEdges()
1045 BBI.BB->CorrectExtraCFGEdges(TBB, FBB, !Cond.empty()); in RemoveExtraEdges()
1111 bool IfConverter::IfConvertSimple(BBInfo &BBI, IfcvtKind Kind) { in IfConvertSimple() argument
1112 BBInfo &TrueBBI = BBAnalysis[BBI.TrueBB->getNumber()]; in IfConvertSimple()
1113 BBInfo &FalseBBI = BBAnalysis[BBI.FalseBB->getNumber()]; in IfConvertSimple()
1117 SmallVector<MachineOperand, 4> Cond(BBI.BrCond.begin(), BBI.BrCond.end()); in IfConvertSimple()
1124 BBI.IsAnalyzed = false; in IfConvertSimple()
1149 BBI.NonPredSize -= TII->RemoveBranch(*BBI.BB); in IfConvertSimple()
1152 CopyAndPredicateBlock(BBI, *CvtBBI, Cond); in IfConvertSimple()
1156 BBI.BB->removeSuccessor(CvtBBI->BB, true); in IfConvertSimple()
1162 BBI.NonPredSize -= TII->RemoveBranch(*BBI.BB); in IfConvertSimple()
1163 MergeBlocks(BBI, *CvtBBI); in IfConvertSimple()
1167 if (!canFallThroughTo(BBI.BB, NextBBI->BB)) { in IfConvertSimple()
1168 InsertUncondBranch(BBI.BB, NextBBI->BB, TII); in IfConvertSimple()
1169 BBI.HasFallThrough = false; in IfConvertSimple()
1183 RemoveExtraEdges(BBI); in IfConvertSimple()
1187 BBI.IsDone = true; in IfConvertSimple()
1188 InvalidatePreds(BBI.BB); in IfConvertSimple()
1197 bool IfConverter::IfConvertTriangle(BBInfo &BBI, IfcvtKind Kind) { in IfConvertTriangle() argument
1198 BBInfo &TrueBBI = BBAnalysis[BBI.TrueBB->getNumber()]; in IfConvertTriangle()
1199 BBInfo &FalseBBI = BBAnalysis[BBI.FalseBB->getNumber()]; in IfConvertTriangle()
1204 SmallVector<MachineOperand, 4> Cond(BBI.BrCond.begin(), BBI.BrCond.end()); in IfConvertTriangle()
1211 BBI.IsAnalyzed = false; in IfConvertTriangle()
1231 if (PBB == BBI.BB) in IfConvertTriangle()
1257 BBNext = MBPI->getEdgeProbability(BBI.BB, NextBBI->BB); in IfConvertTriangle()
1258 BBCvt = MBPI->getEdgeProbability(BBI.BB, CvtBBI->BB); in IfConvertTriangle()
1262 BBI.NonPredSize -= TII->RemoveBranch(*BBI.BB); in IfConvertTriangle()
1265 CopyAndPredicateBlock(BBI, *CvtBBI, Cond, true); in IfConvertTriangle()
1269 BBI.BB->removeSuccessor(CvtBBI->BB, true); in IfConvertTriangle()
1276 BBI.NonPredSize -= TII->RemoveBranch(*BBI.BB); in IfConvertTriangle()
1277 MergeBlocks(BBI, *CvtBBI, false); in IfConvertTriangle()
1293 auto NewTrueBB = getNextBlock(BBI.BB); in IfConvertTriangle()
1296 std::find(BBI.BB->succ_begin(), BBI.BB->succ_end(), NewTrueBB); in IfConvertTriangle()
1297 if (NewTrueBBIter != BBI.BB->succ_end()) in IfConvertTriangle()
1298 BBI.BB->setSuccProbability(NewTrueBBIter, NewNext); in IfConvertTriangle()
1301 TII->InsertBranch(*BBI.BB, CvtBBI->FalseBB, nullptr, RevCond, dl); in IfConvertTriangle()
1302 BBI.BB->addSuccessor(CvtBBI->FalseBB, NewFalse); in IfConvertTriangle()
1309 bool isFallThrough = canFallThroughTo(BBI.BB, NextBBI->BB); in IfConvertTriangle()
1317 MergeBlocks(BBI, *NextBBI); in IfConvertTriangle()
1320 InsertUncondBranch(BBI.BB, NextBBI->BB, TII); in IfConvertTriangle()
1321 BBI.HasFallThrough = false; in IfConvertTriangle()
1328 RemoveExtraEdges(BBI); in IfConvertTriangle()
1332 BBI.IsDone = true; in IfConvertTriangle()
1333 InvalidatePreds(BBI.BB); in IfConvertTriangle()
1344 bool IfConverter::IfConvertDiamond(BBInfo &BBI, IfcvtKind Kind, in IfConvertDiamond() argument
1346 BBInfo &TrueBBI = BBAnalysis[BBI.TrueBB->getNumber()]; in IfConvertDiamond()
1347 BBInfo &FalseBBI = BBAnalysis[BBI.FalseBB->getNumber()]; in IfConvertDiamond()
1360 BBI.IsAnalyzed = false; in IfConvertDiamond()
1375 SmallVector<MachineOperand, 4> RevCond(BBI.BrCond.begin(), BBI.BrCond.end()); in IfConvertDiamond()
1378 SmallVector<MachineOperand, 4> *Cond1 = &BBI.BrCond; in IfConvertDiamond()
1395 BBI.NonPredSize -= TII->RemoveBranch(*BBI.BB); in IfConvertDiamond()
1435 BBI.BB->splice(BBI.BB->end(), BBI1->BB, BBI1->BB->begin(), DI1); in IfConvertDiamond()
1539 MergeBlocks(BBI, *BBI1, TailBB == nullptr); in IfConvertDiamond()
1540 MergeBlocks(BBI, *BBI2, TailBB == nullptr); in IfConvertDiamond()
1553 MachineBasicBlock::const_iterator TI = BBI.BB->getFirstTerminator(); in IfConvertDiamond()
1554 if (TI != BBI.BB->end() && TII->isPredicated(*TI)) in IfConvertDiamond()
1567 MergeBlocks(BBI, TailBBI); in IfConvertDiamond()
1570 BBI.BB->addSuccessor(TailBB, BranchProbability::getOne()); in IfConvertDiamond()
1571 InsertUncondBranch(BBI.BB, TailBB, TII); in IfConvertDiamond()
1572 BBI.HasFallThrough = false; in IfConvertDiamond()
1579 BBI.BB->removeSuccessor(BBI1->BB); in IfConvertDiamond()
1580 BBI.BB->removeSuccessor(BBI2->BB, true); in IfConvertDiamond()
1581 RemoveExtraEdges(BBI); in IfConvertDiamond()
1584 BBI.IsDone = TrueBBI.IsDone = FalseBBI.IsDone = true; in IfConvertDiamond()
1585 InvalidatePreds(BBI.BB); in IfConvertDiamond()
1613 void IfConverter::PredicateBlock(BBInfo &BBI, in PredicateBlock() argument
1619 for (MachineInstr &I : llvm::make_range(BBI.BB->begin(), E)) { in PredicateBlock()
1644 BBI.Predicate.append(Cond.begin(), Cond.end()); in PredicateBlock()
1646 BBI.IsAnalyzed = false; in PredicateBlock()
1647 BBI.NonPredSize = 0; in PredicateBlock()