Lines Matching refs:BI
509 static bool unswitchTrivialBranch(Loop &L, BranchInst &BI, DominatorTree &DT,
512 assert(BI.isConditional() && "Can only unswitch a conditional branch!");
513 LLVM_DEBUG(dbgs() << " Trying to unswitch branch: " << BI << "\n");
522 Value *Cond = skipTrivialSelect(BI.getCondition());
538 auto *LoopExitBB = BI.getSuccessor(0);
542 LoopExitBB = BI.getSuccessor(1);
548 auto *ContinueBB = BI.getSuccessor(1 - LoopExitSuccIdx);
549 auto *ParentBB = BI.getParent();
570 dbgs() << " unswitching trivial invariant conditions for: " << BI
607 assert(LoopExitBB->getUniquePredecessor() == BI.getParent() &&
626 BI.moveBefore(*OldPH, OldPH->end());
627 BI.setCondition(Cond);
631 BI.clone()->insertInto(ParentBB, ParentBB->end());
636 NewBI->setDebugLoc(BI.getDebugLoc());
638 BI.setSuccessor(LoopExitSuccIdx, UnswitchedBB);
639 BI.setSuccessor(1 - LoopExitSuccIdx, NewPH);
644 assert(match(skipTrivialSelect(BI.getCondition()), m_LogicalOr()) &&
648 assert(match(skipTrivialSelect(BI.getCondition()), m_LogicalAnd()) &&
695 ? ConstantInt::getFalse(BI.getContext())
696 : ConstantInt::getTrue(BI.getContext());
1099 auto *BI = dyn_cast<BranchInst>(CurrentBB->getTerminator());
1100 if (!BI || BI->isConditional())
1103 CurrentBB = BI->getSuccessor(0);
1107 auto *BI = dyn_cast<BranchInst>(CurrentTerm);
1108 if (!BI)
1115 if (!BI->isConditional() ||
1116 isa<Constant>(skipTrivialSelect(BI->getCondition())))
1121 if (!unswitchTrivialBranch(L, *BI, DT, LI, SE, MSSAU))
1129 BI = cast<BranchInst>(CurrentBB->getTerminator());
1130 if (BI->isConditional())
1134 CurrentBB = BI->getSuccessor(0);
1315 if (auto *BI = dyn_cast<BranchInst>(ClonedTerminator))
1316 ClonedConditionToErase = BI->getCondition();
1320 Instruction *BI = BranchInst::Create(ClonedSuccBB, ClonedParentBB);
1321 BI->setDebugLoc(ClonedTerminator->getDebugLoc());
2182 BranchInst *BI = dyn_cast<BranchInst>(&TI);
2183 SwitchInst *SI = BI ? nullptr : cast<SwitchInst>(&TI);
2192 assert((SI || (BI && BI->isConditional())) &&
2196 SI || (skipTrivialSelect(BI->getCondition()) == Invariants[0] &&
2202 assert(isa<Instruction>(skipTrivialSelect(BI->getCondition())) &&
2217 Value *Cond = skipTrivialSelect(BI->getCondition());
2233 BI ? BI->getSuccessor(1 - ClonedSucc) : SI->getDefaultDest();
2235 if (BI)
2236 UnswitchedSuccBBs.insert(BI->getSuccessor(ClonedSucc));
2359 if (BI) {
2361 BI->setSuccessor(ClonedSucc, ClonedPH);
2362 BI->setSuccessor(1 - ClonedSucc, LoopPH);
2363 Value *Cond = skipTrivialSelect(BI->getCondition());
2366 // BI (`dyn_cast<BranchInst>(TI)`) is an in-loop instruction hoisted
2368 Cond = new FreezeInst(Cond, Cond->getName() + ".fr", BI->getIterator());
2370 BI->setCondition(Cond);
2422 if (BI) {
2460 assert(BI && "Only branches have partial unswitching.");
2472 FreezeLoopUnswitchCond, BI, &AC, DT);
2526 if (BI && !PartiallyInvariant) {
2548 Direction ? ConstantInt::getTrue(BI->getContext())
2549 : ConstantInt::getFalse(BI->getContext());
2551 Direction ? ConstantInt::getFalse(BI->getContext())
2552 : ConstantInt::getTrue(BI->getContext());
2649 if (BI)
2959 auto *BI = dyn_cast<BranchInst>(BB->getTerminator());
2960 if (!BI || !BI->isConditional() ||
2961 BI->getSuccessor(0) == BI->getSuccessor(1))
2964 AddUnswitchCandidatesForInst(BI, BI->getCondition());
3038 /// Returns true, if metadata on \p BI allows us to optimize branching into \p
3042 bool shouldTryInjectBasingOnMetadata(const BranchInst *BI,
3045 if (!extractBranchWeights(*BI, Weights))
3051 size_t Idx = BI->getSuccessor(0) == TakenSucc ? 0 : 1;
3391 auto &BI = cast<BranchInst>(TI);
3392 Value *Cond = skipTrivialSelect(BI.getCondition());
3394 if (SuccBB == BI.getSuccessor(1))
3397 if (SuccBB == BI.getSuccessor(0))
3400 SuccBB == BI.getSuccessor(0)) ||
3402 SuccBB == BI.getSuccessor(1)))
3435 BranchInst *BI = dyn_cast<BranchInst>(&TI);
3437 !BI || Candidate.hasPendingInjection() ||
3439 Invariants[0] == skipTrivialSelect(BI->getCondition()));
3485 if (BranchInst *BI = dyn_cast<BranchInst>(&TI))
3486 Cond = skipTrivialSelect(BI->getCondition());