Lines Matching refs:PBI

1953     Instruction *PBI = &*I;
1954 // Check whether Inst and PBI generate the same value.
1955 if (Inst->isIdenticalTo(PBI)) {
1956 Inst->replaceAllUsesWith(PBI);
1979 if (BranchInst *PBI = dyn_cast<BranchInst>(PB->getTerminator()))
1980 if (PBI->isConditional() &&
1981 (BI->getSuccessor(0) == PBI->getSuccessor(0) ||
1982 BI->getSuccessor(0) == PBI->getSuccessor(1))) {
2057 BranchInst *PBI = dyn_cast<BranchInst>(PredBlock->getTerminator());
2063 if (PBI == 0 || PBI->isUnconditional() ||
2065 !SafeToMergeTerminators(BI, PBI)) ||
2067 !isProfitableToFoldUnconditional(BI, PBI, Cond, PHIs)))
2075 if (PBI->getSuccessor(0) == TrueDest)
2077 else if (PBI->getSuccessor(1) == FalseDest)
2079 else if (PBI->getSuccessor(0) == FalseDest)
2081 else if (PBI->getSuccessor(1) == TrueDest)
2086 if (PBI->getSuccessor(0) != TrueDest && PBI->getSuccessor(1) != TrueDest)
2110 Worklist.push_back(std::make_pair(PBI->getOperand(0), 0));
2133 DEBUG(dbgs() << "FOLDING BRANCH TO COMMON DEST:\n" << *PBI << *BB);
2134 IRBuilder<> Builder(PBI);
2138 Value *NewCond = PBI->getCondition();
2145 PBI->getCondition()->getName()+".not");
2148 PBI->setCondition(NewCond);
2149 PBI->swapSuccessors();
2156 PredBlock->getInstList().insert(PBI, NewBonus);
2165 PredBlock->getInstList().insert(PBI, New);
2171 cast<Instruction>(Builder.CreateBinOp(Opc, PBI->getCondition(),
2173 PBI->setCondition(NewCond);
2176 bool PredHasWeights = ExtractBranchMetadata(PBI, PredTrueWeight,
2182 if (PBI->getSuccessor(0) == BB) {
2184 // PBI: br i1 %x, BB, FalseDest
2186 //TrueWeight is TrueWeight for PBI * TrueWeight for BI.
2188 //FalseWeight is FalseWeight for PBI * TotalWeight for BI +
2189 // TrueWeight for PBI * FalseWeight for BI.
2196 PBI->setSuccessor(0, TrueDest);
2198 if (PBI->getSuccessor(1) == BB) {
2200 // PBI: br i1 %x, TrueDest, BB
2202 //TrueWeight is TrueWeight for PBI * TotalWeight for BI +
2203 // FalseWeight for PBI * TrueWeight for BI.
2206 //FalseWeight is FalseWeight for PBI * FalseWeight for BI.
2210 PBI->setSuccessor(1, FalseDest);
2217 PBI->setMetadata(LLVMContext::MD_prof,
2221 PBI->setMetadata(LLVMContext::MD_prof, NULL);
2226 PHIs[i]->getIncomingValueForBlock(PBI->getParent()));
2229 if (PBI->getSuccessor(0) == TrueDest) {
2234 cast<Instruction>(Builder.CreateNot(PBI->getCondition(),
2243 PBI->getCondition(), MergedCond,
2251 PBI->getCondition(), New,
2255 cast<Instruction>(Builder.CreateNot(PBI->getCondition(),
2264 PHIs[i]->setIncomingValue(PHIs[i]->getBasicBlockIndex(PBI->getParent()),
2267 // Change PBI from Conditional to Unconditional.
2268 BranchInst *New_PBI = BranchInst::Create(TrueDest, PBI);
2269 EraseTerminatorInstAndDCECond(PBI);
2270 PBI = New_PBI;
2274 // could replace PBI's branch probabilities with BI's.
2279 I->clone()->insertBefore(PBI);
2288 /// that PBI and BI are both conditional branches, and BI is in one of the
2289 /// successor blocks of PBI - PBI branches to BI.
2290 static bool SimplifyCondBranchToCondBranch(BranchInst *PBI, BranchInst *BI) {
2291 assert(PBI->isConditional() && BI->isConditional());
2297 if (PBI->getCondition() == BI->getCondition() &&
2298 PBI->getSuccessor(0) != PBI->getSuccessor(1)) {
2303 bool CondIsTrue = PBI->getSuccessor(0) == BB;
2318 // Okay, we're going to insert the PHI node. Since PBI is not the only
2323 if ((PBI = dyn_cast<BranchInst>(P->getTerminator())) &&
2324 PBI != BI && PBI->isConditional() &&
2325 PBI->getCondition() == BI->getCondition() &&
2326 PBI->getSuccessor(0) != PBI->getSuccessor(1)) {
2327 bool CondIsTrue = PBI->getSuccessor(0) == BB;
2356 if (PBI->getSuccessor(0) == BI->getSuccessor(0))
2358 else if (PBI->getSuccessor(0) == BI->getSuccessor(1))
2360 else if (PBI->getSuccessor(1) == BI->getSuccessor(0))
2362 else if (PBI->getSuccessor(1) == BI->getSuccessor(1))
2370 if (PBI->getSuccessor(PBIOp) == BB)
2376 BasicBlock *CommonDest = PBI->getSuccessor(PBIOp);
2387 DEBUG(dbgs() << "FOLDING BRs:" << *PBI->getParent()
2407 DEBUG(dbgs() << *PBI->getParent()->getParent());
2410 // it alone, but modify PBI.
2413 Value *PBICond = PBI->getCondition();
2414 IRBuilder<true, NoFolder> Builder(PBI);
2425 // Modify PBI to branch on the new condition to the new dests.
2426 PBI->setCondition(Cond);
2427 PBI->setSuccessor(0, CommonDest);
2428 PBI->setSuccessor(1, OtherDest);
2430 // Update branch weight for PBI.
2432 bool PredHasWeights = ExtractBranchMetadata(PBI, PredTrueWeight,
2452 PBI->setMetadata(LLVMContext::MD_prof,
2457 // OtherDest may have phi nodes. If so, add an entry from PBI's
2459 AddPredecessorToBlock(OtherDest, PBI->getParent(), BB);
2461 // We know that the CommonDest already had an edge from PBI to
2463 // entries for BB and PBI's BB. If so, insert a select to make
2469 unsigned PBBIdx = PN->getBasicBlockIndex(PBI->getParent());
2472 // Insert a select in PBI to pick the right value.
2479 DEBUG(dbgs() << "INTO: " << *PBI->getParent());
2480 DEBUG(dbgs() << *PBI->getParent()->getParent());
4007 if (BranchInst *PBI = dyn_cast<BranchInst>((*PI)->getTerminator()))
4008 if (PBI != BI && PBI->isConditional())
4009 if (SimplifyCondBranchToCondBranch(PBI, BI))