-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[VPlan] Add VPPhi subclass for VPInstruction with PHI opcodes.(NFC) #139151
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
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Similarly to VPInstructionWithType and VPIRPhi, add VPPhi as a subclass for VPInstruction. This allows implementing the VPPhiAccessors trait, making available helpers for generic printing of incoming values / blocks and accessors for incoming blocks and values. It will also allow properly verifying def-uses for values used by VPInstructions with PHI opcodes via #124838.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -492,16 +492,7 @@ Value *VPInstruction::generate(VPTransformState &State) { | |
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.VPBB2IRBB.at(getParent()->getCFGPredecessor(0)); | ||
Value *Start = State.get(getOperand(0), VPLane(0)); | ||
PHINode *Phi = State.Builder.CreatePHI(Start->getType(), 2, Name); | ||
Phi->addIncoming(Start, VectorPH); | ||
return Phi; | ||
llvm_unreachable("should be handled by VPPhi::execute"); | ||
} | ||
case Instruction::Select: { | ||
bool OnlyFirstLaneUsed = vputils::onlyFirstLaneUsed(this); | ||
|
@@ -1131,6 +1122,30 @@ void VPInstructionWithType::print(raw_ostream &O, const Twine &Indent, | |
} | ||
#endif | ||
|
||
void VPPhi::execute(VPTransformState &State) { | ||
State.setDebugLocFrom(getDebugLoc()); | ||
assert(getParent() == | ||
getParent()->getPlan()->getVectorLoopRegion()->getEntry() && | ||
"VPInstructions with PHI opcodes must be used for header phis only " | ||
"at the moment"); | ||
BasicBlock *VectorPH = State.CFG.VPBB2IRBB.at(getIncomingBlock(0)); | ||
Value *Start = State.get(getIncomingValue(0), VPLane(0)); | ||
PHINode *Phi = State.Builder.CreatePHI(Start->getType(), 2, getName()); | ||
Phi->addIncoming(Start, VectorPH); | ||
State.set(this, Phi, VPLane(0)); | ||
} | ||
|
||
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) | ||
void VPPhi::print(raw_ostream &O, const Twine &Indent, | ||
VPSlotTracker &SlotTracker) const { | ||
O << Indent << "EMIT "; | ||
printAsOperand(O, SlotTracker); | ||
O << " = phi "; | ||
|
||
printPhiOperands(O, SlotTracker); | ||
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: worth separating this change of how the recipe is printed to a follow-up patch, associated with the test changes? 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. Sounds good, I split this off from the patch and will land separately, thanks |
||
} | ||
#endif | ||
|
||
VPIRInstruction *VPIRInstruction ::create(Instruction &I) { | ||
if (auto *Phi = dyn_cast<PHINode>(&I)) | ||
return new VPIRPhi(*Phi); | ||
|
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.
Can it have any opcode other than PHI?
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.
Nope, dropped, thanks!