-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[VPlan] Remove ResumePhi opcode, use regular PHI instead (NFC). #140405
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
063d70f
f5ee27b
74eddb5
61779cf
801b98d
069767b
d3df2c3
3f3f002
a02b1d5
0b39926
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 |
---|---|---|
|
@@ -733,17 +733,6 @@ Value *VPInstruction::generate(VPTransformState &State) { | |
Value *Addend = State.get(getOperand(1), VPLane(0)); | ||
return Builder.CreatePtrAdd(Ptr, Addend, Name, getGEPNoWrapFlags()); | ||
} | ||
case VPInstruction::ResumePhi: { | ||
auto *NewPhi = | ||
Builder.CreatePHI(State.TypeAnalysis.inferScalarType(this), 2, Name); | ||
for (const auto &[IncVPV, PredVPBB] : | ||
zip(operands(), getParent()->getPredecessors())) { | ||
Value *IncV = State.get(IncVPV, /* IsScalar */ true); | ||
BasicBlock *PredBB = State.CFG.VPBB2IRBB.at(cast<VPBasicBlock>(PredVPBB)); | ||
NewPhi->addIncoming(IncV, PredBB); | ||
} | ||
return NewPhi; | ||
} | ||
case VPInstruction::AnyOf: { | ||
Value *A = State.get(getOperand(0)); | ||
return Builder.CreateOrReduce(A); | ||
|
@@ -847,8 +836,7 @@ bool VPInstruction::isVectorToScalar() const { | |
} | ||
|
||
bool VPInstruction::isSingleScalar() const { | ||
return getOpcode() == VPInstruction::ResumePhi || | ||
getOpcode() == Instruction::PHI; | ||
return getOpcode() == Instruction::PHI; | ||
} | ||
|
||
void VPInstruction::execute(VPTransformState &State) { | ||
|
@@ -934,7 +922,6 @@ bool VPInstruction::onlyFirstLaneUsed(const VPValue *Op) const { | |
case VPInstruction::CanonicalIVIncrementForPart: | ||
case VPInstruction::BranchOnCount: | ||
case VPInstruction::BranchOnCond: | ||
case VPInstruction::ResumePhi: | ||
return true; | ||
case VPInstruction::PtrAdd: | ||
return Op == getOperand(0) || vputils::onlyFirstLaneUsed(this); | ||
|
@@ -991,9 +978,6 @@ void VPInstruction::print(raw_ostream &O, const Twine &Indent, | |
case VPInstruction::ActiveLaneMask: | ||
O << "active lane mask"; | ||
break; | ||
case VPInstruction::ResumePhi: | ||
O << "resume-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. Nit: can retain how resume-phis are printed by checking if a phi is in the scalar preheader when printed in this patch, reducing its test diff and keeping it strictly NFC. Changing its printing can be done separately as a follow up. 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. Done thanks |
||
break; | ||
case VPInstruction::ExplicitVectorLength: | ||
O << "EXPLICIT-VECTOR-LENGTH"; | ||
break; | ||
|
@@ -1101,21 +1085,36 @@ void VPInstructionWithType::print(raw_ostream &O, const Twine &Indent, | |
|
||
void VPPhi::execute(VPTransformState &State) { | ||
State.setDebugLocFrom(getDebugLoc()); | ||
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)); | ||
PHINode *NewPhi = State.Builder.CreatePHI( | ||
State.TypeAnalysis.inferScalarType(this), 2, getName()); | ||
unsigned NumIncoming = getNumIncoming(); | ||
if (getParent() != getParent()->getPlan()->getScalarPreheader()) { | ||
// TODO: Fixup all incoming values of header phis once recipes defining them | ||
// are introduced. | ||
NumIncoming = 1; | ||
} | ||
for (unsigned Idx = 0; Idx != NumIncoming; ++Idx) { | ||
Value *IncV = State.get(getIncomingValue(Idx), VPLane(0)); | ||
BasicBlock *PredBB = State.CFG.VPBB2IRBB.at(getIncomingBlock(Idx)); | ||
NewPhi->addIncoming(IncV, PredBB); | ||
} | ||
State.set(this, NewPhi, VPLane(0)); | ||
} | ||
|
||
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) | ||
void VPPhi::print(raw_ostream &O, const Twine &Indent, | ||
VPSlotTracker &SlotTracker) const { | ||
O << Indent << "EMIT" << (isSingleScalar() ? "-SCALAR" : "") << " "; | ||
printAsOperand(O, SlotTracker); | ||
O << " = phi "; | ||
|
||
printPhiOperands(O, SlotTracker); | ||
const VPBasicBlock *Parent = getParent(); | ||
if (Parent == Parent->getPlan()->getScalarPreheader()) { | ||
// TODO: Use regular printing for resume-phis as well | ||
O << " = resume-phi "; | ||
printOperands(O, SlotTracker); | ||
} else { | ||
O << " = phi "; | ||
printPhiOperands(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.
Worth retaining this documentation somewhere, possibly updated if needed?
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.
This comment wasn't accruate any longer; they now have incoming values for all predecssors, hence being 'full' phis.