-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[VPlan] Invert condition if needed when creating inner regions. #132292
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
29bfcd0
0f7ad9e
fa812b5
26b6cb4
6339346
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 | ||||
---|---|---|---|---|---|---|
|
@@ -420,6 +420,17 @@ static void createLoopRegion(VPlan &Plan, VPBlockBase *HeaderVPB) { | |||||
auto *PreheaderVPBB = HeaderVPB->getPredecessors()[0]; | ||||||
auto *LatchVPBB = HeaderVPB->getPredecessors()[1]; | ||||||
|
||||||
// We are canonicalizing the successors of the latch when introducing the | ||||||
// region. We will exit the region of the latch condition is true; invert the | ||||||
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.
Suggested change
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 |
||||||
// original condition if the original CFG branches to the header on true. | ||||||
if (!LatchVPBB->getSingleSuccessor() && | ||||||
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. Can LatchVPBB have a single successor, should we assert that it has two, following the check that header has two predecessors? 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. At the moment, it may have 1 successor (the header, when vectorizing inner loops, where exit edges are not yet connected; that should be coming soon thought) or 2 (for inner loops when vectorizing outer loops) 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. ok, and in that case there's no terminating conditional branch yet to reverse? May be worth leaving a note. 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,t hanks 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: consider reversing (the above conditional branch which is also terminating ;-) to early-return. 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 |
||||||
LatchVPBB->getSuccessors()[0] == HeaderVPB) { | ||||||
auto *Term = cast<VPBasicBlock>(LatchVPBB)->getTerminator(); | ||||||
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. Assert that Term is a conditional branch, so that we're certain who's first operand we're resetting? 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 |
||||||
auto *Not = new VPInstruction(VPInstruction::Not, {Term->getOperand(0)}); | ||||||
Not->insertBefore(Term); | ||||||
Term->setOperand(0, Not); | ||||||
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. Also swap the successors to keep successors and branch condition in sync, even though both successors are soon to be removed. As in canonicalizing the two predecessors of header. 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, |
||||||
} | ||||||
|
||||||
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. Better to perform this canonicalization in a separate canonicalizeLatch(), analogous to canonical[ize]Header()?
or possibly fused into 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. Fused, thanks! |
||||||
VPBlockUtils::disconnectBlocks(PreheaderVPBB, HeaderVPB); | ||||||
VPBlockUtils::disconnectBlocks(LatchVPBB, HeaderVPB); | ||||||
VPBlockBase *Succ = LatchVPBB->getSingleSuccessor(); | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,9 @@ bool VPlanTransforms::tryToConvertVPInstructionsToVPRecipes( | |
make_early_inc_range(make_range(VPBB->begin(), EndIter))) { | ||
|
||
VPValue *VPV = Ingredient.getVPSingleValue(); | ||
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: using 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. Can rename separately, thanks |
||
if (!VPV->getUnderlyingValue()) | ||
continue; | ||
|
||
Instruction *Inst = cast<Instruction>(VPV->getUnderlyingValue()); | ||
|
||
VPRecipeBase *NewRecipe = nullptr; | ||
|
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