Lines Matching full:si

331                              Instruction *SI, bool ForSinking = false);
334 bool isSelectHighlyPredictable(const SelectLike SI);
354 Scaled64 getMispredictionCost(const SelectLike SI, const Scaled64 CondCost);
358 const SelectLike SI);
361 bool isSelectKindSupported(const SelectLike SI);
528 /// If \p isTrue is true, return the true value of \p SI, otherwise return
529 /// false value of \p SI. If the true/false value of \p SI is defined by any
533 getTrueOrFalseValue(SelectOptimizeImpl::SelectLike SI, bool isTrue, in getTrueOrFalseValue() argument
537 for (SelectInst *DefSI = dyn_cast<SelectInst>(SI.getI()); in getTrueOrFalseValue()
540 if (DefSI->getCondition() == SI.getCondition()) in getTrueOrFalseValue()
542 else // Handle inverted SI in getTrueOrFalseValue()
546 if (isa<BinaryOperator>(SI.getI())) { in getTrueOrFalseValue()
547 assert(SI.getI()->getOpcode() == Instruction::Or && in getTrueOrFalseValue()
549 V = SI.getFalseValue(); in getTrueOrFalseValue()
601 for (SelectLike SI : ASI) { in convertProfitableSIGroups() local
604 if (auto *TI = dyn_cast_or_null<Instruction>(SI.getTrueValue())) { in convertProfitableSIGroups()
606 getExclBackwardsSlice(TI, TrueSlice, SI.getI(), true); in convertProfitableSIGroups()
610 if (auto *FI = dyn_cast_or_null<Instruction>(SI.getFalseValue())) { in convertProfitableSIGroups()
611 if (isa<SelectInst>(SI.getI()) || !FI->hasOneUse()) { in convertProfitableSIGroups()
613 getExclBackwardsSlice(FI, FalseSlice, SI.getI(), true); in convertProfitableSIGroups()
648 SelectLike SI = ASI.front(); in convertProfitableSIGroups() local
650 BasicBlock *StartBlock = SI.getI()->getParent(); in convertProfitableSIGroups()
666 auto DIt = SI.getI()->getIterator(); in convertProfitableSIGroups()
670 if (match(&*DIt, m_Not(m_Specific(SI.getCondition())))) in convertProfitableSIGroups()
688 // Iterate over all instructions in between SI and LastSI, not including in convertProfitableSIGroups()
689 // SI itself. These are all the variable assignments that happen "in the in convertProfitableSIGroups()
691 auto R = make_range(std::next(SI.getI()->getIterator()), in convertProfitableSIGroups()
725 FalseBranch->setDebugLoc(SI.getI()->getDebugLoc()); in convertProfitableSIGroups()
746 IRBuilder<> IB(SI.getI()); in convertProfitableSIGroups()
747 auto *CondFr = IB.CreateFreeze(SI.getCondition(), in convertProfitableSIGroups()
748 SI.getCondition()->getName() + ".frozen"); in convertProfitableSIGroups()
751 for (auto SI : ASI) in convertProfitableSIGroups() local
752 INS.insert(SI.getI()); in convertProfitableSIGroups()
758 SelectLike SI = *It; in convertProfitableSIGroups() local
760 PHINode *PN = PHINode::Create(SI.getType(), 2, ""); in convertProfitableSIGroups()
762 PN->takeName(SI.getI()); in convertProfitableSIGroups()
763 PN->addIncoming(getTrueOrFalseValue(SI, true, INS, IB), TrueBlock); in convertProfitableSIGroups()
764 PN->addIncoming(getTrueOrFalseValue(SI, false, INS, IB), FalseBlock); in convertProfitableSIGroups()
765 PN->setDebugLoc(SI.getI()->getDebugLoc()); in convertProfitableSIGroups()
766 SI.getI()->replaceAllUsesWith(PN); in convertProfitableSIGroups()
767 INS.erase(SI.getI()); in convertProfitableSIGroups()
770 IB.CreateCondBr(CondFr, TT, FT, SI.getI()); in convertProfitableSIGroups()
773 for (auto SI : ASI) in convertProfitableSIGroups() local
774 SI.getI()->eraseFromParent(); in convertProfitableSIGroups()
783 if (SelectLike SI = SelectLike::match(I)) { in collectSelectGroups() local
788 SIGroup.push_back(SI); in collectSelectGroups()
799 if (match(NI, m_Not(m_Specific(SI.getCondition())))) { in collectSelectGroups()
810 if (NSI && SI.getCondition() == NSI.getCondition()) { in collectSelectGroups()
813 m_Not(m_Specific(SI.getCondition())))) { in collectSelectGroups()
823 if (!isSelectKindSupported(SI)) in collectSelectGroups()
828 for (auto SI : SIGroup) in collectSelectGroups()
829 dbgs() << " " << *SI.getI() << "\n"; in collectSelectGroups()
877 for (SelectLike SI : ASI) { in findProfitableSIGroupsInnerLoops() local
878 SelectCost = std::max(SelectCost, InstCostMap[SI.getI()].PredCost); in findProfitableSIGroupsInnerLoops()
879 BranchCost = std::max(BranchCost, InstCostMap[SI.getI()].NonPredCost); in findProfitableSIGroupsInnerLoops()
902 SelectLike SI = ASI.front(); in isConvertToBranchProfitableBase() local
903 LLVM_DEBUG(dbgs() << "Analyzing select group containing " << *SI.getI() in isConvertToBranchProfitableBase()
905 OptimizationRemark OR(DEBUG_TYPE, "SelectOpti", SI.getI()); in isConvertToBranchProfitableBase()
906 OptimizationRemarkMissed ORmiss(DEBUG_TYPE, "SelectOpti", SI.getI()); in isConvertToBranchProfitableBase()
909 if (PSI->isColdBlock(SI.getI()->getParent(), BFI)) { in isConvertToBranchProfitableBase()
917 if (SI.getI()->getMetadata(LLVMContext::MD_unpredictable)) { in isConvertToBranchProfitableBase()
926 if (isSelectHighlyPredictable(SI) && TLI->isPredictableSelectExpensive()) { in isConvertToBranchProfitableBase()
952 static bool extractBranchWeights(const SelectOptimizeImpl::SelectLike SI, in extractBranchWeights() argument
954 if (isa<SelectInst>(SI.getI())) in extractBranchWeights()
955 return extractBranchWeights(*SI.getI(), TrueVal, FalseVal); in extractBranchWeights()
978 for (SelectLike SI : ASI) { in hasExpensiveColdOperand() local
982 ColdI = dyn_cast_or_null<Instruction>(SI.getTrueValue()); in hasExpensiveColdOperand()
985 ColdI = dyn_cast_or_null<Instruction>(SI.getFalseValue()); in hasExpensiveColdOperand()
990 getExclBackwardsSlice(ColdI, ColdSlice, SI.getI()); in hasExpensiveColdOperand()
1011 // Check if it is safe to move LoadI next to the SI.
1014 static bool isSafeToSinkLoad(Instruction *LoadI, Instruction *SI) { in isSafeToSinkLoad() argument
1016 if (LoadI->getParent() != SI->getParent()) in isSafeToSinkLoad()
1019 while (&*It != SI) { in isSafeToSinkLoad()
1035 Instruction *SI, in getExclBackwardsSlice() argument
1062 if (ForSinking && II->mayReadFromMemory() && !isSafeToSinkLoad(II, SI)) in getExclBackwardsSlice()
1080 bool SelectOptimizeImpl::isSelectHighlyPredictable(const SelectLike SI) { in isSelectHighlyPredictable() argument
1082 if (extractBranchWeights(SI, TrueWeight, FalseWeight)) { in isSelectHighlyPredictable()
1214 auto SI = SImap.at(&I); in computeLoopCosts() local
1215 Scaled64 TrueOpCost = SI.getTrueOpCost(InstCostMap, TTI); in computeLoopCosts()
1216 Scaled64 FalseOpCost = SI.getFalseOpCost(InstCostMap, TTI); in computeLoopCosts()
1218 getPredictedPathCost(TrueOpCost, FalseOpCost, SI); in computeLoopCosts()
1221 if (auto *CI = dyn_cast<Instruction>(SI.getCondition())) in computeLoopCosts()
1224 Scaled64 MispredictCost = getMispredictionCost(SI, CondCost); in computeLoopCosts()
1247 for (SelectLike SI : ASI) in getSImap() local
1248 SImap.try_emplace(SI.getI(), SI); in getSImap()
1262 SelectOptimizeImpl::getMispredictionCost(const SelectLike SI, in getMispredictionCost() argument
1271 if (isSelectHighlyPredictable(SI)) in getMispredictionCost()
1289 const SelectLike SI) { in getPredictedPathCost() argument
1292 if (extractBranchWeights(SI, TrueWeight, FalseWeight)) { in getPredictedPathCost()
1309 bool SelectOptimizeImpl::isSelectKindSupported(const SelectLike SI) { in isSelectKindSupported() argument
1310 bool VectorCond = !SI.getCondition()->getType()->isIntegerTy(1); in isSelectKindSupported()
1314 if (SI.getType()->isVectorTy()) in isSelectKindSupported()