[VectorDistribute] Allow duplication of operation chains#23937
Open
sommerlukas wants to merge 2 commits intoiree-org:mainfrom
Open
[VectorDistribute] Allow duplication of operation chains#23937sommerlukas wants to merge 2 commits intoiree-org:mainfrom
sommerlukas wants to merge 2 commits intoiree-org:mainfrom
Conversation
Signed-off-by: Lukas Sommer <lukas.sommer@amd.com>
compiler/src/iree/compiler/Codegen/Common/test/vector_layout_analysis_chain_cloning.mlir
Show resolved
Hide resolved
Groverkss
reviewed
Mar 27, 2026
Comment on lines
+487
to
+488
| arith::CmpIOp, arith::SelectOp, arith::ExtSIOp, arith::ExtUIOp, | ||
| arith::TruncIOp, arith::IndexCastOp>(op); |
Contributor
There was a problem hiding this comment.
use elementwise op traits. all elementwise ops are cheap.
| if (isDuplicatableLeaf(op)) { | ||
| return true; | ||
| } | ||
| return op->getNumResults() == 1 && isPure(op) && |
Contributor
There was a problem hiding this comment.
i dont think we should check if num elements == 1. Even if it isn't, these things are cheap.
Comment on lines
+498
to
+499
| // The chain is built bottom-up (from consumer toward producers). | ||
| constexpr unsigned kMaxChainLength = 8; |
Contributor
There was a problem hiding this comment.
promote this outside the function.
Signed-off-by: Lukas Sommer <lukas.sommer@amd.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If a value gets assigned two different layouts, the VectorLayoutAnalysis tries to duplicate that value if it is easily duplicatable to avoid layout transformation via LDS.
So far, this duplication was limited to single operations. This PR extends this to bounded chains of easy to duplicate/recompute values.
The motivation for this change is masks. CSE will deduplicate
create_maskoperations. After early materialization ofcreate_maskoperations, the mask is transformed to a chain of operations:As the mask is used for different operations, it will receive multiple different layouts. Therefore, we would materialize these masks to LDS for layout transformation.
By allowing chains of cheap operations to be duplicated, we avoid that materialization in LDS.
This is part of #23415.
Assisted-by: Claude Code