Lines Matching defs:SI
267 Instruction *SI, bool ForSinking = false);
270 bool isSelectHighlyPredictable(const SelectLike SI);
295 Scaled64 getMispredictionCost(const SelectLike SI, const Scaled64 CondCost);
299 const SelectLike SI);
302 bool isSelectKindSupported(const SelectLike SI);
481 SelectOptimizeImpl::SelectLike &SI, bool isTrue,
484 Value *V = isTrue ? SI.getTrueValue() : SI.getFalseValue();
492 auto *BO = cast<BinaryOperator>(SI.getI());
499 auto CondIdx = SI.getConditionOpIndex();
561 for (SelectLike &SI : ASI.Selects) {
562 if (!isa<SelectInst>(SI.getI()))
566 if (auto *TI = dyn_cast_or_null<Instruction>(SI.getTrueValue())) {
568 getExclBackwardsSlice(TI, TrueSlice, SI.getI(), true);
572 if (auto *FI = dyn_cast_or_null<Instruction>(SI.getFalseValue())) {
573 if (isa<SelectInst>(SI.getI()) || !FI->hasOneUse()) {
575 getExclBackwardsSlice(FI, FalseSlice, SI.getI(), true);
610 SelectLike &SI = ASI.Selects.front();
612 BasicBlock *StartBlock = SI.getI()->getParent();
628 auto DIt = SI.getI()->getIterator();
652 // Iterate over all instructions in between SI and LastSI, not including
653 // SI itself. These are all the variable assignments that happen "in the
655 auto R = make_range(std::next(SI.getI()->getIterator()),
697 FalseBranch->setDebugLoc(SI.getI()->getDebugLoc());
718 IRBuilder<> IB(SI.getI());
728 for (SelectLike &SI : ASI.Selects) {
730 PHINode *PN = PHINode::Create(SI.getType(), 2, "");
732 PN->takeName(SI.getI());
737 if (SG.Condition == SI.getI())
741 SI.getI()->replaceAllUsesWith(PN);
742 auto *TV = getTrueOrFalseValue(SI, true, INS, TrueBlock);
743 auto *FV = getTrueOrFalseValue(SI, false, INS, FalseBlock);
747 PN->setDebugLoc(SI.getI()->getDebugLoc());
750 IB.CreateCondBr(CondFr, TT, FT, SI.getI());
753 for (SelectLike &SI : ASI.Selects)
754 SI.getI()->eraseFromParent();
932 for (auto &SI : SIGroup.Selects)
933 dbgs() << " " << *SI.getI() << "\n";
980 for (SelectLike &SI : ASI.Selects) {
981 SelectCost = std::max(SelectCost, InstCostMap[SI.getI()].PredCost);
982 BranchCost = std::max(BranchCost, InstCostMap[SI.getI()].NonPredCost);
1006 const SelectLike &SI = ASI.Selects.front();
1007 LLVM_DEBUG(dbgs() << "Analyzing select group containing " << *SI.getI()
1009 OptimizationRemark OR(DEBUG_TYPE, "SelectOpti", SI.getI());
1010 OptimizationRemarkMissed ORmiss(DEBUG_TYPE, "SelectOpti", SI.getI());
1013 if (PSI->isColdBlock(SI.getI()->getParent(), BFI)) {
1021 if (SI.getI()->getMetadata(LLVMContext::MD_unpredictable)) {
1030 if (isSelectHighlyPredictable(SI) && TLI->isPredictableSelectExpensive()) {
1049 auto *BB = SI.getI()->getParent();
1068 static bool extractBranchWeights(const SelectOptimizeImpl::SelectLike SI,
1070 if (isa<SelectInst>(SI.getI()))
1071 return extractBranchWeights(*SI.getI(), TrueVal, FalseVal);
1094 for (SelectLike SI : ASI.Selects) {
1098 ColdI = dyn_cast_or_null<Instruction>(SI.getTrueValue());
1101 ColdI = dyn_cast_or_null<Instruction>(SI.getFalseValue());
1106 getExclBackwardsSlice(ColdI, ColdSlice, SI.getI());
1127 // Check if it is safe to move LoadI next to the SI.
1130 static bool isSafeToSinkLoad(Instruction *LoadI, Instruction *SI) {
1132 if (LoadI->getParent() != SI->getParent())
1135 while (&*It != SI) {
1151 Instruction *SI,
1178 if (ForSinking && II->mayReadFromMemory() && !isSafeToSinkLoad(II, SI))
1196 bool SelectOptimizeImpl::isSelectHighlyPredictable(const SelectLike SI) {
1198 if (extractBranchWeights(SI, TrueWeight, FalseWeight)) {
1331 auto SI = SImap.at(&I);
1333 Scaled64 TrueOpCost = SI.getOpCostOnBranch(true, InstCostMap, TTI);
1334 Scaled64 FalseOpCost = SI.getOpCostOnBranch(false, InstCostMap, TTI);
1336 getPredictedPathCost(TrueOpCost, FalseOpCost, SI);
1342 Scaled64 MispredictCost = getMispredictionCost(SI, CondCost);
1365 for (const SelectLike &SI : ASI.Selects)
1366 SImap.try_emplace(SI.getI(), SI);
1374 for (const SelectLike &SI : ASI.Selects)
1375 SImap.try_emplace(SI.getI(), &ASI);
1389 SelectOptimizeImpl::getMispredictionCost(const SelectLike SI,
1398 if (isSelectHighlyPredictable(SI))
1416 const SelectLike SI) {
1419 if (extractBranchWeights(SI, TrueWeight, FalseWeight)) {
1436 bool SelectOptimizeImpl::isSelectKindSupported(const SelectLike SI) {
1438 if (SI.getType()->isVectorTy())