-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[VPlan] Construct immutable VPIRBBs for exit blocks at construction(NFC) #128374
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
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 |
|---|---|---|
|
|
@@ -3426,6 +3426,11 @@ class VPlan { | |
| /// VPIRBasicBlock wrapping the header of the original scalar loop. | ||
| VPIRBasicBlock *ScalarHeader; | ||
|
|
||
| /// Immutable list of VPIRBasicBlocks wrapping the exit blocks of the original | ||
| /// scalar loop. Note that some exit blocks may be unreachable at the moment, | ||
| /// e.g. if the scalar epilogue always executes. | ||
| SmallVector<VPIRBasicBlock *, 2> ExitBlocks; | ||
|
|
||
| /// Holds the VFs applicable to this VPlan. | ||
| SmallSetVector<ElementCount, 2> VFs; | ||
|
|
||
|
|
@@ -3559,11 +3564,13 @@ class VPlan { | |
| /// Return the VPIRBasicBlock wrapping the header of the scalar loop. | ||
| VPIRBasicBlock *getScalarHeader() const { return ScalarHeader; } | ||
|
|
||
| /// Return an iterator range over the VPIRBasicBlock wrapping the exit blocks | ||
| /// of the VPlan, that is leaf nodes except the scalar header. Defined in | ||
| /// VPlanHCFG, as the definition of the type needs access to the definitions | ||
| /// of VPBlockShallowTraversalWrapper. | ||
| auto getExitBlocks(); | ||
| /// Return an ArrayRef containing VPIRBasicBlocks wrapping the exit blocks of | ||
| /// the original scalar loop. | ||
| ArrayRef<VPIRBasicBlock *> getExitBlocks() const { return ExitBlocks; } | ||
|
Collaborator
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. This admittedly may be more involved if ExitBlocks are heald as an IRBBToVPExitBlock map.
Contributor
Author
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. Left as vector for now, as |
||
|
|
||
| /// Return the VPIRBasicBlock corresponding to \p IRBB. \p IRBB must be an | ||
| /// exit block. | ||
|
Comment on lines
+3571
to
+3572
Collaborator
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. "must" - if IRBB is not an exit block, an assert is triggered, or null is returned?
Contributor
Author
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. Added an assert, rather than just relying on dereferenceing the end iterator. |
||
| VPIRBasicBlock *getExitBlock(BasicBlock *IRBB) const; | ||
|
|
||
| /// Returns true if \p VPBB is an exit block. | ||
| bool isExitBlock(VPBlockBase *VPBB); | ||
|
|
||
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.
All exit blocks are expected to be reachable, in the long run.
The exit blocks of Plan include only exit.block and optionally latch.exit, as depicted in
https://llvm.org/docs/Vectorizers.html#epilogue-vectorization and https://llvm.org/docs/Vectorizers.html#early-exit-vectorization, where the scalar header is expected to eventually reach the above exit blocks.
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.
Yep, once we connect the exits also to the scalar loop