-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[NFC][LoopVectorize] Make replaceVPBBWithIRVPBB more efficient #111514
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
389ab09
6c45224
3da4e4e
d1b45da
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 |
|---|---|---|
|
|
@@ -1005,12 +1005,14 @@ static void replaceVPBBWithIRVPBB(VPBasicBlock *VPBB, BasicBlock *IRBB) { | |
| R.moveBefore(*IRVPBB, IRVPBB->end()); | ||
| } | ||
| VPBlockBase *PredVPBB = VPBB->getSinglePredecessor(); | ||
| VPBlockUtils::disconnectBlocks(PredVPBB, VPBB); | ||
| VPBlockUtils::connectBlocks(PredVPBB, IRVPBB); | ||
| for (auto *Succ : to_vector(VPBB->getSuccessors())) { | ||
| VPBlockUtils::connectBlocks(IRVPBB, Succ); | ||
| VPBlockUtils::disconnectBlocks(VPBB, Succ); | ||
| } | ||
| PredVPBB->replaceSuccessor(VPBB, IRVPBB); | ||
david-arm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| IRVPBB->setPredecessors({PredVPBB}); | ||
|
||
| for (auto *Succ : to_vector(VPBB->getSuccessors())) | ||
| Succ->replacePredecessor(VPBB, IRVPBB); | ||
| IRVPBB->setSuccessors(VPBB->getSuccessors()); | ||
|
|
||
| VPBB->clearSuccessors(); | ||
| VPBB->clearPredecessors(); | ||
david-arm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| delete VPBB; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -556,6 +556,26 @@ class VPBlockBase { | |
| return getEnclosingBlockWithPredecessors()->getSinglePredecessor(); | ||
| } | ||
|
|
||
| /// This function replaces one predecessor with another, useful when | ||
| /// trying to replace an old block in the CFG with a new one. | ||
| void replacePredecessor(VPBlockBase *Old, VPBlockBase *New) { | ||
| auto I = find(Predecessors, Old); | ||
| assert(I != Predecessors.end()); | ||
| assert(Old->getParent() == New->getParent() && | ||
| "replaced predecessor must have the same parent"); | ||
| *I = New; | ||
|
||
| } | ||
|
|
||
| /// This function replaces one successor with another, useful when | ||
| /// trying to replace an old block in the CFG with a new one. | ||
| void replaceSuccessor(VPBlockBase *Old, VPBlockBase *New) { | ||
| auto I = find(Successors, Old); | ||
| assert(I != Successors.end()); | ||
| assert(Old->getParent() == New->getParent() && | ||
| "replaced successor must have the same parent"); | ||
| *I = New; | ||
| } | ||
|
|
||
| /// Set a given VPBlockBase \p Successor as the single successor of this | ||
| /// VPBlockBase. This VPBlockBase is not added as predecessor of \p Successor. | ||
| /// This VPBlockBase must have no successors. | ||
|
|
||
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 assert of having a single predecessor is now lost, yet still documented. The function traverses multiple predecessors, but probably works and tested for single predecessor only, as VPBB is still expected to be free of phi recipes? Better be clear, assert and test what is supported.