Skip to content

Flatten indices#1145

Draft
Hardcode84 wants to merge 3 commits intoiree-org:mainfrom
Hardcode84:flatten-indices
Draft

Flatten indices#1145
Hardcode84 wants to merge 3 commits intoiree-org:mainfrom
Hardcode84:flatten-indices

Conversation

@Hardcode84
Copy link
Copy Markdown
Contributor

No description provided.

Hardcode84 and others added 3 commits March 18, 2026 18:54
Design for flatten_read_indices pass that converts Read ops from N-D
logical indices to 1-D physical indices using a LINEAR_INDEX symbol,
with expression-keyed bounds for mask preservation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Ivan Butygin <ivan.butygin@gmail.com>
Introduce flatten_read_indices pass that converts Read ops from N-D
logical indices to 1-D physical offsets using a LINEAR_INDEX symbol.
Handles mapping resolution, shared memory distributed shapes, and
expression-keyed bounds via delinearize_index. Skips reads with
dynamic mapping values.

LIT tests need CHECK pattern updates for the new flat codegen output.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Ivan Butygin <ivan.butygin@gmail.com>
For each Read with LINEAR_INDEX inside a loop body, computes
stride = simplify(flat(IV + step) - flat(IV)). When the stride is
loop-invariant, rewrites the flat offset to base + IV * stride form.
This makes strength reduction trivial for downstream backends.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Ivan Butygin <ivan.butygin@gmail.com>
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.

2 participants