Lines Matching refs:SI
304 Instruction *SI, bool ForSinking = false);
307 bool isSelectHighlyPredictable(const SelectLike SI);
327 Scaled64 getMispredictionCost(const SelectLike SI, const Scaled64 CondCost);
331 const SelectLike SI);
334 bool isSelectKindSupported(const SelectLike SI);
506 getTrueOrFalseValue(SelectOptimizeImpl::SelectLike SI, bool isTrue, in getTrueOrFalseValue() argument
510 for (SelectInst *DefSI = dyn_cast<SelectInst>(SI.getI()); in getTrueOrFalseValue()
513 assert(DefSI->getCondition() == SI.getCondition() && in getTrueOrFalseValue()
518 if (isa<BinaryOperator>(SI.getI())) { in getTrueOrFalseValue()
519 assert(SI.getI()->getOpcode() == Instruction::Or && in getTrueOrFalseValue()
521 V = SI.getFalseValue(); in getTrueOrFalseValue()
573 for (SelectLike SI : ASI) { in convertProfitableSIGroups() local
576 if (auto *TI = dyn_cast_or_null<Instruction>(SI.getTrueValue())) { in convertProfitableSIGroups()
578 getExclBackwardsSlice(TI, TrueSlice, SI.getI(), true); in convertProfitableSIGroups()
582 if (auto *FI = dyn_cast_or_null<Instruction>(SI.getFalseValue())) { in convertProfitableSIGroups()
583 if (isa<SelectInst>(SI.getI()) || !FI->hasOneUse()) { in convertProfitableSIGroups()
585 getExclBackwardsSlice(FI, FalseSlice, SI.getI(), true); in convertProfitableSIGroups()
620 SelectLike SI = ASI.front(); in convertProfitableSIGroups() local
622 BasicBlock *StartBlock = SI.getI()->getParent(); in convertProfitableSIGroups()
632 auto DIt = SI.getI()->getIterator(); in convertProfitableSIGroups()
655 auto R = make_range(std::next(SI.getI()->getIterator()), in convertProfitableSIGroups()
689 FalseBranch->setDebugLoc(SI.getI()->getDebugLoc()); in convertProfitableSIGroups()
710 IRBuilder<> IB(SI.getI()); in convertProfitableSIGroups()
711 auto *CondFr = IB.CreateFreeze(SI.getCondition(), in convertProfitableSIGroups()
712 SI.getCondition()->getName() + ".frozen"); in convertProfitableSIGroups()
715 for (auto SI : ASI) in convertProfitableSIGroups() local
716 INS.insert(SI.getI()); in convertProfitableSIGroups()
722 SelectLike SI = *It; in convertProfitableSIGroups() local
724 PHINode *PN = PHINode::Create(SI.getType(), 2, ""); in convertProfitableSIGroups()
726 PN->takeName(SI.getI()); in convertProfitableSIGroups()
727 PN->addIncoming(getTrueOrFalseValue(SI, true, INS, IB), TrueBlock); in convertProfitableSIGroups()
728 PN->addIncoming(getTrueOrFalseValue(SI, false, INS, IB), FalseBlock); in convertProfitableSIGroups()
729 PN->setDebugLoc(SI.getI()->getDebugLoc()); in convertProfitableSIGroups()
730 SI.getI()->replaceAllUsesWith(PN); in convertProfitableSIGroups()
731 INS.erase(SI.getI()); in convertProfitableSIGroups()
734 IB.CreateCondBr(CondFr, TT, FT, SI.getI()); in convertProfitableSIGroups()
737 for (auto SI : ASI) in convertProfitableSIGroups() local
738 SI.getI()->eraseFromParent(); in convertProfitableSIGroups()
747 if (SelectLike SI = SelectLike::match(I)) { in collectSelectGroups() local
752 SIGroup.push_back(SI); in collectSelectGroups()
767 if (NSI && SI.getCondition() == NSI.getCondition()) { in collectSelectGroups()
776 if (!isSelectKindSupported(SI)) in collectSelectGroups()
824 for (SelectLike SI : ASI) { in findProfitableSIGroupsInnerLoops() local
825 SelectCost = std::max(SelectCost, InstCostMap[SI.getI()].PredCost); in findProfitableSIGroupsInnerLoops()
826 BranchCost = std::max(BranchCost, InstCostMap[SI.getI()].NonPredCost); in findProfitableSIGroupsInnerLoops()
849 SelectLike SI = ASI.front(); in isConvertToBranchProfitableBase() local
850 LLVM_DEBUG(dbgs() << "Analyzing select group containing " << SI.getI() in isConvertToBranchProfitableBase()
852 OptimizationRemark OR(DEBUG_TYPE, "SelectOpti", SI.getI()); in isConvertToBranchProfitableBase()
853 OptimizationRemarkMissed ORmiss(DEBUG_TYPE, "SelectOpti", SI.getI()); in isConvertToBranchProfitableBase()
856 if (PSI->isColdBlock(SI.getI()->getParent(), BFI)) { in isConvertToBranchProfitableBase()
864 if (SI.getI()->getMetadata(LLVMContext::MD_unpredictable)) { in isConvertToBranchProfitableBase()
873 if (isSelectHighlyPredictable(SI) && TLI->isPredictableSelectExpensive()) { in isConvertToBranchProfitableBase()
899 static bool extractBranchWeights(const SelectOptimizeImpl::SelectLike SI, in extractBranchWeights() argument
901 if (isa<SelectInst>(SI.getI())) in extractBranchWeights()
902 return extractBranchWeights(*SI.getI(), TrueVal, FalseVal); in extractBranchWeights()
925 for (SelectLike SI : ASI) { in hasExpensiveColdOperand() local
929 ColdI = dyn_cast_or_null<Instruction>(SI.getTrueValue()); in hasExpensiveColdOperand()
932 ColdI = dyn_cast_or_null<Instruction>(SI.getFalseValue()); in hasExpensiveColdOperand()
937 getExclBackwardsSlice(ColdI, ColdSlice, SI.getI()); in hasExpensiveColdOperand()
961 static bool isSafeToSinkLoad(Instruction *LoadI, Instruction *SI) { in isSafeToSinkLoad() argument
963 if (LoadI->getParent() != SI->getParent()) in isSafeToSinkLoad()
966 while (&*It != SI) { in isSafeToSinkLoad()
982 Instruction *SI, in getExclBackwardsSlice() argument
1009 if (ForSinking && II->mayReadFromMemory() && !isSafeToSinkLoad(II, SI)) in getExclBackwardsSlice()
1027 bool SelectOptimizeImpl::isSelectHighlyPredictable(const SelectLike SI) { in isSelectHighlyPredictable() argument
1029 if (extractBranchWeights(SI, TrueWeight, FalseWeight)) { in isSelectHighlyPredictable()
1161 auto SI = SImap.at(&I); in computeLoopCosts() local
1162 Scaled64 TrueOpCost = SI.getTrueOpCost(InstCostMap, TTI); in computeLoopCosts()
1163 Scaled64 FalseOpCost = SI.getFalseOpCost(InstCostMap, TTI); in computeLoopCosts()
1165 getPredictedPathCost(TrueOpCost, FalseOpCost, SI); in computeLoopCosts()
1168 if (auto *CI = dyn_cast<Instruction>(SI.getCondition())) in computeLoopCosts()
1171 Scaled64 MispredictCost = getMispredictionCost(SI, CondCost); in computeLoopCosts()
1194 for (SelectLike SI : ASI) in getSImap() local
1195 SImap.try_emplace(SI.getI(), SI); in getSImap()
1209 SelectOptimizeImpl::getMispredictionCost(const SelectLike SI, in getMispredictionCost() argument
1218 if (isSelectHighlyPredictable(SI)) in getMispredictionCost()
1236 const SelectLike SI) { in getPredictedPathCost() argument
1239 if (extractBranchWeights(SI, TrueWeight, FalseWeight)) { in getPredictedPathCost()
1256 bool SelectOptimizeImpl::isSelectKindSupported(const SelectLike SI) { in isSelectKindSupported() argument
1257 bool VectorCond = !SI.getCondition()->getType()->isIntegerTy(1); in isSelectKindSupported()
1261 if (SI.getType()->isVectorTy()) in isSelectKindSupported()