Lines Matching defs:Phi
64 /// Determines if Phi may have been type-promoted. If Phi has a single user
65 /// that ANDs the Phi with a type mask, return the user. RT is updated to
68 static Instruction *lookThroughAnd(PHINode *Phi, Type *&RT,
71 if (!Phi->hasOneUse())
72 return Phi;
75 Instruction *I, *J = cast<Instruction>(Phi->use_begin()->getUser());
82 RT = IntegerType::get(Phi->getContext(), Bits);
83 Visited.insert(Phi);
88 return Phi;
179 // Check if a given Phi node can be recognized as an ordered reduction for
182 Instruction *Exit, PHINode *Phi) {
202 if (Kind == RecurKind::FAdd && Op0 != Phi && Op1 != Phi)
204 if (Kind == RecurKind::FMulAdd && Exit->getOperand(2) != Phi)
207 LLVM_DEBUG(dbgs() << "LV: Found an ordered reduction: Phi: " << *Phi
214 PHINode *Phi, RecurKind Kind, Loop *TheLoop, FastMathFlags FuncFMF,
217 if (Phi->getNumIncomingValues() != 2)
221 if (Phi->getParent() != TheLoop->getHeader())
226 Value *RdxStart = Phi->getIncomingValueForBlock(TheLoop->getLoopPreheader());
255 Type *RecurrenceType = Phi->getType();
258 Instruction *Start = Phi;
264 // Return early if the recurrence kind does not match the type of Phi. If the
276 Start = lookThroughAnd(Phi, RecurrenceType, VisitedInsts, CastInsts);
289 // The first instruction in the use-def chain of the Phi node that requires
361 if (Cur != Phi && IsAPhi && Cur->getParent() == Phi->getParent())
372 // the starting value (the Phi or an AND instruction if the Phi has been
376 isRecurrenceInstr(TheLoop, Phi, Cur, Kind, ReduxDesc, FuncFMF);
416 if (IsAPhi && Cur != Phi && !areAllUsesIn(Cur, VisitedInsts))
455 if (ExitInstruction != nullptr || Cur == Phi)
461 if (!is_contained(Phi->operands(), Cur))
488 !isAnyOfPattern(TheLoop, Phi, UI, IgnoredVal)
494 if (UI == Phi)
515 if (!is_contained(Phi->operands(), IntermediateStore->getValueOperand())) {
541 checkOrderedReduction(Kind, ExactFPMathInst, ExitInstruction, Phi);
543 if (Start != Phi) {
838 bool RecurrenceDescriptor::isReductionPHI(PHINode *Phi, Loop *TheLoop,
851 if (AddReductionVar(Phi, RecurKind::Add, TheLoop, FMF, RedDes, DB, AC, DT,
853 LLVM_DEBUG(dbgs() << "Found an ADD reduction PHI." << *Phi << "\n");
856 if (AddReductionVar(Phi, RecurKind::Mul, TheLoop, FMF, RedDes, DB, AC, DT,
858 LLVM_DEBUG(dbgs() << "Found a MUL reduction PHI." << *Phi << "\n");
861 if (AddReductionVar(Phi, RecurKind::Or, TheLoop, FMF, RedDes, DB, AC, DT,
863 LLVM_DEBUG(dbgs() << "Found an OR reduction PHI." << *Phi << "\n");
866 if (AddReductionVar(Phi, RecurKind::And, TheLoop, FMF, RedDes, DB, AC, DT,
868 LLVM_DEBUG(dbgs() << "Found an AND reduction PHI." << *Phi << "\n");
871 if (AddReductionVar(Phi, RecurKind::Xor, TheLoop, FMF, RedDes, DB, AC, DT,
873 LLVM_DEBUG(dbgs() << "Found a XOR reduction PHI." << *Phi << "\n");
876 if (AddReductionVar(Phi, RecurKind::SMax, TheLoop, FMF, RedDes, DB, AC, DT,
878 LLVM_DEBUG(dbgs() << "Found a SMAX reduction PHI." << *Phi << "\n");
881 if (AddReductionVar(Phi, RecurKind::SMin, TheLoop, FMF, RedDes, DB, AC, DT,
883 LLVM_DEBUG(dbgs() << "Found a SMIN reduction PHI." << *Phi << "\n");
886 if (AddReductionVar(Phi, RecurKind::UMax, TheLoop, FMF, RedDes, DB, AC, DT,
888 LLVM_DEBUG(dbgs() << "Found a UMAX reduction PHI." << *Phi << "\n");
891 if (AddReductionVar(Phi, RecurKind::UMin, TheLoop, FMF, RedDes, DB, AC, DT,
893 LLVM_DEBUG(dbgs() << "Found a UMIN reduction PHI." << *Phi << "\n");
896 if (AddReductionVar(Phi, RecurKind::IAnyOf, TheLoop, FMF, RedDes, DB, AC, DT,
899 << *Phi << "\n");
902 if (AddReductionVar(Phi, RecurKind::FMul, TheLoop, FMF, RedDes, DB, AC, DT,
904 LLVM_DEBUG(dbgs() << "Found an FMult reduction PHI." << *Phi << "\n");
907 if (AddReductionVar(Phi, RecurKind::FAdd, TheLoop, FMF, RedDes, DB, AC, DT,
909 LLVM_DEBUG(dbgs() << "Found an FAdd reduction PHI." << *Phi << "\n");
912 if (AddReductionVar(Phi, RecurKind::FMax, TheLoop, FMF, RedDes, DB, AC, DT,
914 LLVM_DEBUG(dbgs() << "Found a float MAX reduction PHI." << *Phi << "\n");
917 if (AddReductionVar(Phi, RecurKind::FMin, TheLoop, FMF, RedDes, DB, AC, DT,
919 LLVM_DEBUG(dbgs() << "Found a float MIN reduction PHI." << *Phi << "\n");
922 if (AddReductionVar(Phi, RecurKind::FAnyOf, TheLoop, FMF, RedDes, DB, AC, DT,
925 << " PHI." << *Phi << "\n");
928 if (AddReductionVar(Phi, RecurKind::FMulAdd, TheLoop, FMF, RedDes, DB, AC, DT,
930 LLVM_DEBUG(dbgs() << "Found an FMulAdd reduction PHI." << *Phi << "\n");
933 if (AddReductionVar(Phi, RecurKind::FMaximum, TheLoop, FMF, RedDes, DB, AC, DT,
935 LLVM_DEBUG(dbgs() << "Found a float MAXIMUM reduction PHI." << *Phi << "\n");
938 if (AddReductionVar(Phi, RecurKind::FMinimum, TheLoop, FMF, RedDes, DB, AC, DT,
940 LLVM_DEBUG(dbgs() << "Found a float MINIMUM reduction PHI." << *Phi << "\n");
947 bool RecurrenceDescriptor::isFixedOrderRecurrence(PHINode *Phi, Loop *TheLoop,
951 if (Phi->getParent() != TheLoop->getHeader() ||
952 Phi->getNumIncomingValues() != 2)
963 if (Phi->getBasicBlockIndex(Preheader) < 0 ||
964 Phi->getBasicBlockIndex(Latch) < 0)
969 auto *Previous = dyn_cast<Instruction>(Phi->getIncomingValueForBlock(Latch));
977 if (PrevPhi->getParent() != Phi->getParent())
994 BasicBlock *PhiBB = Phi->getParent();
1022 WorkList.push_back(Phi);
1131 RecurrenceDescriptor::getReductionOpChain(PHINode *Phi, Loop *L) const {
1135 // Search down from the Phi to the LoopExitInstr, looking for instructions
1194 if (Inc0 == Phi)
1196 else if (Inc1 == Phi)
1212 // Check that the Phi has one (or two for min/max) uses, plus an extra use
1214 if (!Phi->hasNUses(ExpectedUses + ExtraPhiUses))
1217 Instruction *Cur = getNextInstruction(Phi);
1275 bool InductionDescriptor::isFPInductionPHI(PHINode *Phi, const Loop *TheLoop,
1280 assert(Phi->getType()->isFloatingPointTy() && "Unexpected Phi type");
1282 if (TheLoop->getHeader() != Phi->getParent())
1287 if (Phi->getNumIncomingValues() != 2)
1290 if (TheLoop->contains(Phi->getIncomingBlock(0))) {
1291 BEValue = Phi->getIncomingValue(0);
1292 StartValue = Phi->getIncomingValue(1);
1294 assert(TheLoop->contains(Phi->getIncomingBlock(1)) &&
1295 "Unexpected Phi node in the loop");
1296 BEValue = Phi->getIncomingValue(1);
1297 StartValue = Phi->getIncomingValue(0);
1306 if (BOp->getOperand(0) == Phi)
1308 else if (BOp->getOperand(1) == Phi)
1311 if (BOp->getOperand(0) == Phi)
1433 bool InductionDescriptor::isInductionPHI(PHINode *Phi, const Loop *TheLoop,
1436 Type *PhiTy = Phi->getType();
1447 return isFPInductionPHI(Phi, TheLoop, PSE.getSE(), D);
1449 const SCEV *PhiScev = PSE.getSCEV(Phi);
1454 AR = PSE.getAsAddRec(Phi);
1471 return isInductionPHI(Phi, TheLoop, PSE.getSE(), D, AR, &Casts);
1474 return isInductionPHI(Phi, TheLoop, PSE.getSE(), D, AR);
1478 PHINode *Phi, const Loop *TheLoop, ScalarEvolution *SE,
1481 Type *PhiTy = Phi->getType();
1487 const SCEV *PhiScev = Expr ? Expr : SE->getSCEV(Phi);
1503 // This function assumes that InductionPhi is called only on Phi nodes
1505 // the current Phi is not present inside the loop header.
1506 assert(Phi->getParent() == AR->getLoop()->getHeader()
1507 && "Invalid Phi node, not present in loop header");
1510 Phi->getIncomingValueForBlock(AR->getLoop()->getLoopPreheader());
1525 dyn_cast<BinaryOperator>(Phi->getIncomingValueForBlock(Latch));