Raising: rewrite pointer induction to indexed accesses - #3011
Open
wsmoses wants to merge 2 commits into
Open
Conversation
A loop that walks a pointer forward by a constant stride each iteration (mfem's y[i] accumulation loops) carries it as an iter arg no tensor can stand for. The pointer is a pure function of the induction variable, so accesses through it rebase onto the init pointer at orig + k*stride and the loop rebuilds without the pointer iter args. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD
Extends the rewrite to the shapes rotated do-while lowerings produce: - a used final pointer materializes as the init advanced by the whole trip; statically known trips fold to a constant so downstream users stay affine - the advance stride may be a loop-invariant runtime value (an inner loop's materialized whole-trip advance); its computation chain is cloned above the loop when it lives inside the body - a dead-in-body iter arg that re-yields another induction's advance (a lagging copy) is dropped; its used result becomes select(trip>0, base final, own init), or the base final alone when the init is poison - static strides compose into the affine access map instead of degrading the access to an arith-indexed memref.load Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD
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.
Stacks on #3006.
A loop that walks a pointer forward by a constant stride each iteration (mfem's
*y++ += ...accumulation loops inhybridization_ext.cpp) carries the pointer as an iter arg no tensor can stand for. The pointer is a pure function of the induction variable, so accesses through it rebase onto the init pointer atorig + k*stride(with the byte stride converted into the view's element units) and the loop rebuilds without the pointer iter args; dead carried pointers drop with it.Part of #2968.
🤖 Generated with Claude Code
https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD