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