-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[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 3 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 |
---|---|---|
|
@@ -276,6 +276,11 @@ InstructionCost VPRecipeBase::computeCost(ElementCount VF, | |
VPCostContext &Ctx) const { | ||
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, | ||
|
@@ -418,6 +423,7 @@ bool VPInstruction::canGenerateScalarForFirstLane() const { | |
return true; | ||
switch (Opcode) { | ||
case Instruction::ICmp: | ||
case Instruction::PHI: | ||
case Instruction::Select: | ||
case VPInstruction::BranchOnCond: | ||
case VPInstruction::BranchOnCount: | ||
|
@@ -457,6 +463,14 @@ Value *VPInstruction::generate(VPTransformState &State) { | |
} | ||
|
||
switch (getOpcode()) { | ||
case Instruction::PHI: { | ||
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. Somewhere it should be documented that VPInstructions of PHI opcode are used to model header phi's only. 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 a comment here, thanks 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. Thanks! Perhaps worth an assert? VPInstructions with phi opcodes could be used for non-header phi's prior to predication. Eventually also for uniform branches, and out-of-loop branches. 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 assert, thanks! Will generalize this using #129389 once it lands |
||
// At the moment, VPInstructions with PHI opcodes are only user for scalar header phis. | ||
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 VPInstruction::Not: { | ||
Value *A = State.get(getOperand(0)); | ||
return Builder.CreateNot(A, Name); | ||
|
@@ -771,7 +785,7 @@ bool VPInstruction::isVectorToScalar() const { | |
} | ||
|
||
bool VPInstruction::isSingleScalar() const { | ||
return getOpcode() == VPInstruction::ResumePhi; | ||
return getOpcode() == VPInstruction::ResumePhi || getOpcode() == Instruction::PHI; | ||
} | ||
|
||
#if !defined(NDEBUG) | ||
|
@@ -849,6 +863,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 +3308,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()); | ||
|
@@ -3675,22 +3692,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