-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[VPlan] Use VPInstruction for VPScalarPHIRecipe. (NFCI) #129767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b05ac80
4a8d4da
af491b4
0d9e1fb
0b65489
963bc78
b279a74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,6 +277,12 @@ InstructionCost VPRecipeBase::computeCost(ElementCount VF, | |
llvm_unreachable("subclasses should implement computeCost"); | ||
} | ||
|
||
bool VPRecipeBase::isPhi() const { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit, is this missing a newline above? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added, thanks |
||
return (getVPDefID() >= VPFirstPHISC && getVPDefID() <= VPLastPHISC) || | ||
(isa<VPInstruction>(this) && | ||
cast<VPInstruction>(this)->getOpcode() == Instruction::PHI); | ||
} | ||
|
||
InstructionCost | ||
VPPartialReductionRecipe::computeCost(ElementCount VF, | ||
VPCostContext &Ctx) const { | ||
|
@@ -418,6 +424,7 @@ bool VPInstruction::canGenerateScalarForFirstLane() const { | |
return true; | ||
switch (Opcode) { | ||
case Instruction::ICmp: | ||
case Instruction::PHI: | ||
case Instruction::Select: | ||
case VPInstruction::BranchOnCond: | ||
case VPInstruction::BranchOnCount: | ||
|
@@ -467,6 +474,17 @@ Value *VPInstruction::generate(VPTransformState &State) { | |
Value *B = State.get(getOperand(1), OnlyFirstLaneUsed); | ||
return Builder.CreateCmp(getPredicate(), A, B, Name); | ||
} | ||
case Instruction::PHI: { | ||
assert(getParent() == | ||
getParent()->getPlan()->getVectorLoopRegion()->getEntry() && | ||
"VPInstructions with PHI opcodes must be used for header phis only " | ||
"at the moment"); | ||
BasicBlock *VectorPH = State.CFG.getPreheaderBBFor(this); | ||
Value *Start = State.get(getOperand(0), VPLane(0)); | ||
PHINode *Phi = State.Builder.CreatePHI(Start->getType(), 2, Name); | ||
Phi->addIncoming(Start, VectorPH); | ||
return Phi; | ||
} | ||
case Instruction::Select: { | ||
bool OnlyFirstLaneUsed = vputils::onlyFirstLaneUsed(this); | ||
Value *Cond = State.get(getOperand(0), OnlyFirstLaneUsed); | ||
|
@@ -771,7 +789,8 @@ bool VPInstruction::isVectorToScalar() const { | |
} | ||
|
||
bool VPInstruction::isSingleScalar() const { | ||
return getOpcode() == VPInstruction::ResumePhi; | ||
return getOpcode() == VPInstruction::ResumePhi || | ||
getOpcode() == Instruction::PHI; | ||
} | ||
|
||
#if !defined(NDEBUG) | ||
|
@@ -849,6 +868,8 @@ bool VPInstruction::onlyFirstLaneUsed(const VPValue *Op) const { | |
switch (getOpcode()) { | ||
default: | ||
return false; | ||
case Instruction::PHI: | ||
return true; | ||
case Instruction::ICmp: | ||
case Instruction::Select: | ||
case Instruction::Or: | ||
|
@@ -3292,11 +3313,12 @@ void VPWidenPointerInductionRecipe::execute(VPTransformState &State) { | |
BasicBlock *VectorPH = State.CFG.getPreheaderBBFor(this); | ||
PHINode *NewPointerPhi = nullptr; | ||
if (CurrentPart == 0) { | ||
auto *IVR = cast<VPHeaderPHIRecipe>(&getParent() | ||
->getPlan() | ||
->getVectorLoopRegion() | ||
->getEntryBasicBlock() | ||
->front()); | ||
auto *IVR = getParent() | ||
->getPlan() | ||
->getVectorLoopRegion() | ||
->getEntryBasicBlock() | ||
->front() | ||
.getVPSingleValue(); | ||
Comment on lines
+3316
to
+3321
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Independently: is there a better way to retrieve IVR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be part of the operands. Will look into this separately. |
||
PHINode *CanonicalIV = cast<PHINode>(State.get(IVR, /*IsScalar*/ true)); | ||
NewPointerPhi = PHINode::Create(ScStValueType, 2, "pointer.phi", | ||
CanonicalIV->getIterator()); | ||
|
@@ -3665,22 +3687,3 @@ void VPEVLBasedIVPHIRecipe::print(raw_ostream &O, const Twine &Indent, | |
printOperands(O, SlotTracker); | ||
} | ||
#endif | ||
|
||
void VPScalarPHIRecipe::execute(VPTransformState &State) { | ||
BasicBlock *VectorPH = State.CFG.getPreheaderBBFor(this); | ||
Value *Start = State.get(getStartValue(), VPLane(0)); | ||
PHINode *Phi = State.Builder.CreatePHI(Start->getType(), 2, Name); | ||
Phi->addIncoming(Start, VectorPH); | ||
Phi->setDebugLoc(getDebugLoc()); | ||
State.set(this, Phi, /*IsScalar=*/true); | ||
} | ||
|
||
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) | ||
void VPScalarPHIRecipe::print(raw_ostream &O, const Twine &Indent, | ||
VPSlotTracker &SlotTracker) const { | ||
O << Indent << "SCALAR-PHI "; | ||
printAsOperand(O, SlotTracker); | ||
O << " = phi "; | ||
printOperands(O, SlotTracker); | ||
} | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done thanks