-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[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 1 commit
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 | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -1074,9 +1074,15 @@ void VPlan::execute(VPTransformState *State) { | |||||||
| Inc->setOperand(0, State->get(IV->getLastUnrolledPartOperand())); | ||||||||
| continue; | ||||||||
| } | ||||||||
| if (auto *VPI = dyn_cast<VPInstruction>(&R)) { | ||||||||
| Value *Phi = State->get(VPI, true); | ||||||||
| Value *Val = State->get(VPI->getOperand(1), true); | ||||||||
| cast<PHINode>(Phi)->addIncoming(Val, VectorLatchBB); | ||||||||
| continue; | ||||||||
| } | ||||||||
|
|
||||||||
| auto *PhiR = cast<VPHeaderPHIRecipe>(&R); | ||||||||
| bool NeedsScalar = isa<VPScalarPHIRecipe>(PhiR) || | ||||||||
| bool NeedsScalar = | ||||||||
|
||||||||
| bool NeedsScalar = | |
| // VPInstructions currently model scalar Phis only. | |
| bool NeedsScalar = isa<VPInstruction>(PhiR) || |
(w/o it can drop enclosing ()).
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
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.
| Value *Phi = State->get(PhiR, NeedsScalar); | |
| // VPHeaderPHIRecipe supports getBackedgeValue() but VPInstruction does not. | |
| Value *BackedgeValue = State->get(PhiR>getOperand(1), NeedsScalar); |
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
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -71,6 +71,10 @@ Type *VPTypeAnalysis::inferScalarTypeForRecipe(const VPInstruction *R) { | |||||||||
| } | ||||||||||
| case VPInstruction::ExplicitVectorLength: | ||||||||||
| return Type::getIntNTy(Ctx, 32); | ||||||||||
| case Instruction::PHI: | ||||||||||
| // Avoid inferring the type for other operands, as this may lead to infinite | ||||||||||
| // recursions for cycles. | ||||||||||
|
||||||||||
| // Avoid inferring the type for other operands, as this may lead to infinite | |
| // recursions for cycles. | |
| // Infer the type of first operand only, as other operands of header phi's may | |
| // lead to infinite recursion. |
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!
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -277,6 +277,11 @@ InstructionCost VPRecipeBase::computeCost(ElementCount VF, | |||||||||
| VPCostContext &Ctx) const { | ||||||||||
| llvm_unreachable("subclasses should implement computeCost"); | ||||||||||
| } | ||||||||||
| bool VPRecipeBase::isPhi() const { | ||||||||||
|
Contributor
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?
Contributor
Author
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 { | |||||||||
| if (isSingleScalar() || isVectorToScalar()) | ||||||||||
| return true; | ||||||||||
| switch (Opcode) { | ||||||||||
| case Instruction::PHI: | ||||||||||
| case Instruction::ICmp: | ||||||||||
|
||||||||||
| case Instruction::PHI: | |
| case Instruction::ICmp: | |
| case Instruction::ICmp: | |
| case Instruction::PHI: |
lex order?
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!
Outdated
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.
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 comment
The 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Added assert, thanks!
Will generalize this using #129389 once it lands
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.
Independently: is there a better way to retrieve IVR?
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.
It should be part of the operands. Will look into this separately.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -143,12 +143,13 @@ bool VPlanVerifier::verifyEVLRecipe(const VPInstruction &EVL) const { | |
| }) | ||
| .Case<VPWidenStoreEVLRecipe, VPReductionEVLRecipe>( | ||
| [&](const VPRecipeBase *S) { return VerifyEVLUse(*S, 2); }) | ||
| .Case<VPWidenLoadEVLRecipe, VPReverseVectorPointerRecipe, | ||
| VPScalarPHIRecipe>( | ||
| .Case<VPWidenLoadEVLRecipe, VPReverseVectorPointerRecipe>( | ||
| [&](const VPRecipeBase *R) { return VerifyEVLUse(*R, 1); }) | ||
| .Case<VPScalarCastRecipe>( | ||
| [&](const VPScalarCastRecipe *S) { return VerifyEVLUse(*S, 0); }) | ||
| .Case<VPInstruction>([&](const VPInstruction *I) { | ||
| if (I->getOpcode() == Instruction::PHI) | ||
| return VerifyEVLUse(*I, I->getNumOperands() - 1); | ||
|
||
| if (I->getOpcode() != Instruction::Add) { | ||
| errs() << "EVL is used as an operand in non-VPInstruction::Add\n"; | ||
| return false; | ||
|
|
||
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.
Suffice to
so State->get() works for both VPHeaderPHIRecipes and VPInstructions.
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!