-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[VPlan] Use VPlan predecessors in VPWidenPHIRecipe (NFC). #126388
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
ebc7ac6
29a43e8
e5c2270
25b218c
4195c8b
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 |
---|---|---|
|
@@ -136,19 +136,23 @@ void PlainCFGBuilder::fixPhiNodes() { | |
// predecessor is the first operand of the recipe. | ||
assert(Phi->getNumOperands() == 2); | ||
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. (independent) Error message. 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 in 620a515 |
||
BasicBlock *LoopPred = L->getLoopPredecessor(); | ||
VPPhi->addIncoming( | ||
getOrCreateVPOperand(Phi->getIncomingValueForBlock(LoopPred)), | ||
BB2VPBB[LoopPred]); | ||
VPPhi->addOperand( | ||
getOrCreateVPOperand(Phi->getIncomingValueForBlock(LoopPred))); | ||
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. (independent) This first operand can be set when creating the VPWidenPHIRecipe, only the second operand requires backpatching. |
||
BasicBlock *LoopLatch = L->getLoopLatch(); | ||
VPPhi->addIncoming( | ||
getOrCreateVPOperand(Phi->getIncomingValueForBlock(LoopLatch)), | ||
BB2VPBB[LoopLatch]); | ||
VPPhi->addOperand( | ||
getOrCreateVPOperand(Phi->getIncomingValueForBlock(LoopLatch))); | ||
continue; | ||
} | ||
|
||
for (unsigned I = 0; I != Phi->getNumOperands(); ++I) | ||
VPPhi->addIncoming(getOrCreateVPOperand(Phi->getIncomingValue(I)), | ||
BB2VPBB[Phi->getIncomingBlock(I)]); | ||
// Add operands for VPPhi in the order matching its predecessors in VPlan. | ||
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. (independent) The operands of non-header VPWidenPHIRecipes can be set when creating it, rather than here. 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 in 30f44c9 |
||
DenseMap<const VPBasicBlock *, VPValue *> VPPredToIncomingValue; | ||
for (unsigned I = 0; I != Phi->getNumOperands(); ++I) { | ||
VPPredToIncomingValue[BB2VPBB[Phi->getIncomingBlock(I)]] = | ||
getOrCreateVPOperand(Phi->getIncomingValue(I)); | ||
} | ||
for (VPBlockBase *Pred : VPPhi->getParent()->getPredecessors()) | ||
VPPhi->addOperand( | ||
VPPredToIncomingValue.lookup(Pred->getExitingBasicBlock())); | ||
} | ||
} | ||
|
||
|
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.
Follow-up: make VPWidenPHIRecipe a VPInstruction by inlining both getIncomingValue() and getIncomingBlock() (in VPlan the latter fits a VPBB rather than a phi recipe) into their only user - fixNonInductionPHIs().
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.
I am not sure if
VPInstruction
is the best place, as it may be beneficial to have an easier/more direct way to check if the node is phi-like. But it can probably share most of the logic with VPScalarPhiRecipe eventually.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.
Making VPWidenPHIRecipe be a VPInstruction would simplify "buildLoop" VPlan produced by HCFGBuilder, making it more consistent ("Widen"? All recipes are scalar at this point) and aligned with "wrapInput" VPlan/Region/Blocks which consist of VPIRInstructions - for phi's and non-phi's alike (with the option of introducing other recipes between them).