Skip to content

[Codegen] Add pass to absorb swizzle hints into alloc attributes#24000

Open
Yu-Zhewen wants to merge 1 commit intoiree-org:mainfrom
Yu-Zhewen:pipeliner-swizzle-hint-1
Open

[Codegen] Add pass to absorb swizzle hints into alloc attributes#24000
Yu-Zhewen wants to merge 1 commit intoiree-org:mainfrom
Yu-Zhewen:pipeliner-swizzle-hint-1

Conversation

@Yu-Zhewen
Copy link
Copy Markdown
Contributor

@Yu-Zhewen Yu-Zhewen commented Apr 2, 2026

Part 1/3 of enabling XOR swizzle with pipelining (#23919).

Overall plan: SwizzleHintOp in the SSA chain blocks both memref::multiBuffer and scf::pipelineForLoop. The fix absorbs the hint into an alloc attribute before pipelining, preserves it through multi-buffering, then re-inserts hints at leaf users afterward.

This PR: Adds AbsorbSwizzleHintToAllocPass, which moves swizzle info from SwizzleHintOp to an iree_codegen.swizzle attribute on the defining memref.alloc and erases the hint op. The pass is not yet wired into any pipeline.

Assisted-by: Cursor (Claude)

Part 1/3 of enabling XOR swizzle with software pipelining (iree-org#23919).

Adds AbsorbSwizzleHintToAllocPass, which moves swizzle info from
SwizzleHintOp to an iree_codegen.swizzle attribute on the defining
memref.alloc and erases the hint op. The pass is not yet wired into
any pipeline.

Assisted-by: Cursor (Claude)
Signed-off-by: Yu-Zhewen <zhewenyu@amd.com>
Made-with: Cursor
Copy link
Copy Markdown
Member

@jerryyin jerryyin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one question

static LogicalResult
absorbSwizzleHintToAlloc(RewriterBase &rewriter,
IREE::Codegen::SwizzleHintOp hintOp) {
auto allocOp = hintOp.getOperand().getDefiningOp<memref::AllocOp>();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Question] Is this guaranteed for allocation to be its immediate parent?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So have we made a decision where to resolve the swizzling? do we resolve it at the memory spot, or at the loading/storing operations?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants