[LDS] Add fallback for CoalescedGatherDMA lowering.#23560
Merged
Conversation
Contributor
lialan
commented
Feb 24, 2026
- When gather_to_lds lowering fails due to DMA size alignment, fall back to element-by-element coalesced vector.transfer_read/vector.transfer_write.
- Each lane transfers one element per iteration across the subgroup.
- Remainder elements guarded by scf.if for partial iterations.
- OOB handling replicates the fast path's outermost-index-replacement trick.
- New lit tests for 1D, 2D, gather, and OOB fallback cases.
…lowering. * When gather_to_lds lowering fails due to DMA size alignment, fall back to element-by-element coalesced vector.transfer_read/vector.transfer_write. * Each lane transfers one element per iteration across the subgroup. * Remainder elements guarded by scf.if for partial iterations. * OOB handling replicates the fast path's outermost-index-replacement trick. * New lit tests for 1D, 2D, gather, and OOB fallback cases. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
qedawkins
reviewed
Feb 26, 2026
Contributor
qedawkins
left a comment
There was a problem hiding this comment.
Some mostly minor comments
...iler/src/iree/compiler/Codegen/Common/GPU/test/amdgpu_lower_coalesced_dma_to_gather_lds.mlir
Outdated
Show resolved
Hide resolved
...iler/src/iree/compiler/Codegen/Common/GPU/test/amdgpu_lower_coalesced_dma_to_gather_lds.mlir
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/GPU/AMDGPULowerCoalescedDMAToGatherLDS.cpp
Show resolved
Hide resolved
...iler/src/iree/compiler/Codegen/Common/GPU/test/amdgpu_lower_coalesced_dma_to_gather_lds.mlir
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/GPU/AMDGPULowerCoalescedDMAToGatherLDS.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/GPU/AMDGPULowerCoalescedDMAToGatherLDS.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/GPU/AMDGPULowerCoalescedDMAToGatherLDS.cpp
Outdated
Show resolved
Hide resolved
compiler/src/iree/compiler/Codegen/Common/GPU/AMDGPULowerCoalescedDMAToGatherLDS.cpp
Outdated
Show resolved
Hide resolved
* Remove redundant fallback pattern constructor (benefit=1 is default). * Use llvm::to_vector for linearBasis construction. * Use !inBoundsAttr->empty() instead of size() > 0. * Use llvm::map_to_vector for outerDimOffsets construction. * Remove stale comment about future fallback lowering path. * Capture SSA values and check offsets in remainder iteration tests (1D, 2D). * Verify in_bounds=[false] (default, omitted) on OOB transfer_read. * Add fallback_with_outer_dims test for non-contiguous strided memref with outer dimension iteration. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
qedawkins
approved these changes
Feb 27, 2026
krzysz00
reviewed
Feb 28, 2026
| for (Attribute attr : *inBounds) { | ||
| if (!cast<BoolAttr>(attr).getValue()) { | ||
| return rewriter.notifyMatchFailure( | ||
| dmaOp, "in_bounds with OOB dimensions requires " |
Contributor
There was a problem hiding this comment.
... hold on, did we empirically confirm this? Do we know that if statements around amdgpu.gather_to_lds don't work?
And ... what should be happening is that OOB on non-buffers goes to the fallback path?
| MLIRContext *context = &getContext(); | ||
| RewritePatternSet patterns(context); | ||
| patterns.add<LowerCoalescedGatherDMAPattern>(context, dmaSizes); | ||
| patterns.add<LowerCoalescedGatherDMAFallbackPattern>(context); |
Contributor
There was a problem hiding this comment.
Let's use pattern benefits to run the lowering before the fallback.
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.