Lines Matching defs:Phi
65 /// Determines if Phi may have been type-promoted. If Phi has a single user
66 /// that ANDs the Phi with a type mask, return the user. RT is updated to
69 static Instruction *lookThroughAnd(PHINode *Phi, Type *&RT,
72 if (!Phi->hasOneUse())
73 return Phi;
76 Instruction *I, *J = cast<Instruction>(Phi->use_begin()->getUser());
83 RT = IntegerType::get(Phi->getContext(), Bits);
84 Visited.insert(Phi);
89 return Phi;
180 // Check if a given Phi node can be recognized as an ordered reduction for
183 Instruction *Exit, PHINode *Phi) {
203 if (Kind == RecurKind::FAdd && Op0 != Phi && Op1 != Phi)
205 if (Kind == RecurKind::FMulAdd && Exit->getOperand(2) != Phi)
208 LLVM_DEBUG(dbgs() << "LV: Found an ordered reduction: Phi: " << *Phi
215 PHINode *Phi, RecurKind Kind, Loop *TheLoop, FastMathFlags FuncFMF,
218 if (Phi->getNumIncomingValues() != 2)
222 if (Phi->getParent() != TheLoop->getHeader())
227 Value *RdxStart = Phi->getIncomingValueForBlock(TheLoop->getLoopPreheader());
256 Type *RecurrenceType = Phi->getType();
259 Instruction *Start = Phi;
265 // Return early if the recurrence kind does not match the type of Phi. If the
277 Start = lookThroughAnd(Phi, RecurrenceType, VisitedInsts, CastInsts);
290 // The first instruction in the use-def chain of the Phi node that requires
362 if (Cur != Phi && IsAPhi && Cur->getParent() == Phi->getParent())
373 // the starting value (the Phi or an AND instruction if the Phi has been
377 isRecurrenceInstr(TheLoop, Phi, Cur, Kind, ReduxDesc, FuncFMF, SE);
417 if (IsAPhi && Cur != Phi && !areAllUsesIn(Cur, VisitedInsts))
456 if (ExitInstruction != nullptr || Cur == Phi)
462 if (!is_contained(Phi->operands(), Cur))
489 !isAnyOfPattern(TheLoop, Phi, UI, IgnoredVal)
495 if (UI == Phi)
516 if (!is_contained(Phi->operands(), IntermediateStore->getValueOperand())) {
542 checkOrderedReduction(Kind, ExactFPMathInst, ExitInstruction, Phi);
544 if (Start != Phi) {
924 bool RecurrenceDescriptor::isReductionPHI(PHINode *Phi, Loop *TheLoop,
937 if (AddReductionVar(Phi, RecurKind::Add, TheLoop, FMF, RedDes, DB, AC, DT,
939 LLVM_DEBUG(dbgs() << "Found an ADD reduction PHI." << *Phi << "\n");
942 if (AddReductionVar(Phi, RecurKind::Mul, TheLoop, FMF, RedDes, DB, AC, DT,
944 LLVM_DEBUG(dbgs() << "Found a MUL reduction PHI." << *Phi << "\n");
947 if (AddReductionVar(Phi, RecurKind::Or, TheLoop, FMF, RedDes, DB, AC, DT,
949 LLVM_DEBUG(dbgs() << "Found an OR reduction PHI." << *Phi << "\n");
952 if (AddReductionVar(Phi, RecurKind::And, TheLoop, FMF, RedDes, DB, AC, DT,
954 LLVM_DEBUG(dbgs() << "Found an AND reduction PHI." << *Phi << "\n");
957 if (AddReductionVar(Phi, RecurKind::Xor, TheLoop, FMF, RedDes, DB, AC, DT,
959 LLVM_DEBUG(dbgs() << "Found a XOR reduction PHI." << *Phi << "\n");
962 if (AddReductionVar(Phi, RecurKind::SMax, TheLoop, FMF, RedDes, DB, AC, DT,
964 LLVM_DEBUG(dbgs() << "Found a SMAX reduction PHI." << *Phi << "\n");
967 if (AddReductionVar(Phi, RecurKind::SMin, TheLoop, FMF, RedDes, DB, AC, DT,
969 LLVM_DEBUG(dbgs() << "Found a SMIN reduction PHI." << *Phi << "\n");
972 if (AddReductionVar(Phi, RecurKind::UMax, TheLoop, FMF, RedDes, DB, AC, DT,
974 LLVM_DEBUG(dbgs() << "Found a UMAX reduction PHI." << *Phi << "\n");
977 if (AddReductionVar(Phi, RecurKind::UMin, TheLoop, FMF, RedDes, DB, AC, DT,
979 LLVM_DEBUG(dbgs() << "Found a UMIN reduction PHI." << *Phi << "\n");
982 if (AddReductionVar(Phi, RecurKind::IAnyOf, TheLoop, FMF, RedDes, DB, AC, DT,
985 << *Phi << "\n");
988 if (AddReductionVar(Phi, RecurKind::IFindLastIV, TheLoop, FMF, RedDes, DB, AC,
994 << "FindLastIV reduction PHI." << *Phi << "\n");
997 if (AddReductionVar(Phi, RecurKind::FMul, TheLoop, FMF, RedDes, DB, AC, DT,
999 LLVM_DEBUG(dbgs() << "Found an FMult reduction PHI." << *Phi << "\n");
1002 if (AddReductionVar(Phi, RecurKind::FAdd, TheLoop, FMF, RedDes, DB, AC, DT,
1004 LLVM_DEBUG(dbgs() << "Found an FAdd reduction PHI." << *Phi << "\n");
1007 if (AddReductionVar(Phi, RecurKind::FMax, TheLoop, FMF, RedDes, DB, AC, DT,
1009 LLVM_DEBUG(dbgs() << "Found a float MAX reduction PHI." << *Phi << "\n");
1012 if (AddReductionVar(Phi, RecurKind::FMin, TheLoop, FMF, RedDes, DB, AC, DT,
1014 LLVM_DEBUG(dbgs() << "Found a float MIN reduction PHI." << *Phi << "\n");
1017 if (AddReductionVar(Phi, RecurKind::FAnyOf, TheLoop, FMF, RedDes, DB, AC, DT,
1020 << " PHI." << *Phi << "\n");
1023 if (AddReductionVar(Phi, RecurKind::FMulAdd, TheLoop, FMF, RedDes, DB, AC, DT,
1025 LLVM_DEBUG(dbgs() << "Found an FMulAdd reduction PHI." << *Phi << "\n");
1028 if (AddReductionVar(Phi, RecurKind::FMaximum, TheLoop, FMF, RedDes, DB, AC, DT,
1030 LLVM_DEBUG(dbgs() << "Found a float MAXIMUM reduction PHI." << *Phi << "\n");
1033 if (AddReductionVar(Phi, RecurKind::FMinimum, TheLoop, FMF, RedDes, DB, AC, DT,
1035 LLVM_DEBUG(dbgs() << "Found a float MINIMUM reduction PHI." << *Phi << "\n");
1042 bool RecurrenceDescriptor::isFixedOrderRecurrence(PHINode *Phi, Loop *TheLoop,
1046 if (Phi->getParent() != TheLoop->getHeader() ||
1047 Phi->getNumIncomingValues() != 2)
1058 if (Phi->getBasicBlockIndex(Preheader) < 0 ||
1059 Phi->getBasicBlockIndex(Latch) < 0)
1064 auto *Previous = dyn_cast<Instruction>(Phi->getIncomingValueForBlock(Latch));
1072 if (PrevPhi->getParent() != Phi->getParent())
1089 BasicBlock *PhiBB = Phi->getParent();
1117 WorkList.push_back(Phi);
1167 RecurrenceDescriptor::getReductionOpChain(PHINode *Phi, Loop *L) const {
1171 // Search down from the Phi to the LoopExitInstr, looking for instructions
1230 if (Inc0 == Phi)
1232 else if (Inc1 == Phi)
1248 // Check that the Phi has one (or two for min/max) uses, plus an extra use
1250 if (!Phi->hasNUses(ExpectedUses + ExtraPhiUses))
1253 Instruction *Cur = getNextInstruction(Phi);
1311 bool InductionDescriptor::isFPInductionPHI(PHINode *Phi, const Loop *TheLoop,
1316 assert(Phi->getType()->isFloatingPointTy() && "Unexpected Phi type");
1318 if (TheLoop->getHeader() != Phi->getParent())
1323 if (Phi->getNumIncomingValues() != 2)
1326 if (TheLoop->contains(Phi->getIncomingBlock(0))) {
1327 BEValue = Phi->getIncomingValue(0);
1328 StartValue = Phi->getIncomingValue(1);
1330 assert(TheLoop->contains(Phi->getIncomingBlock(1)) &&
1331 "Unexpected Phi node in the loop");
1332 BEValue = Phi->getIncomingValue(1);
1333 StartValue = Phi->getIncomingValue(0);
1342 if (BOp->getOperand(0) == Phi)
1344 else if (BOp->getOperand(1) == Phi)
1347 if (BOp->getOperand(0) == Phi)
1469 bool InductionDescriptor::isInductionPHI(PHINode *Phi, const Loop *TheLoop,
1472 Type *PhiTy = Phi->getType();
1483 return isFPInductionPHI(Phi, TheLoop, PSE.getSE(), D);
1485 const SCEV *PhiScev = PSE.getSCEV(Phi);
1490 AR = PSE.getAsAddRec(Phi);
1507 return isInductionPHI(Phi, TheLoop, PSE.getSE(), D, AR, &Casts);
1510 return isInductionPHI(Phi, TheLoop, PSE.getSE(), D, AR);
1514 PHINode *Phi, const Loop *TheLoop, ScalarEvolution *SE,
1517 Type *PhiTy = Phi->getType();
1523 const SCEV *PhiScev = Expr ? Expr : SE->getSCEV(Phi);
1539 // This function assumes that InductionPhi is called only on Phi nodes
1541 // the current Phi is not present inside the loop header.
1542 assert(Phi->getParent() == AR->getLoop()->getHeader()
1543 && "Invalid Phi node, not present in loop header");
1546 Phi->getIncomingValueForBlock(AR->getLoop()->getLoopPreheader());
1561 dyn_cast<BinaryOperator>(Phi->getIncomingValueForBlock(Latch));