Raising: unroll invariant-yield do-whiles - #3013
Open
wsmoses wants to merge 1 commit into
Open
Conversation
A rotated do-while whose yields are loop-invariant (or in-body values computed only from invariants) repeats its state after one iteration, so a terminating loop runs at most twice: unroll to the first body plus a guarded second, tolerating side ops in the after region (the barrier between halves of a ping-pong clones ahead of the second body). The unroll clones and erases whole host regions - a do-while wrapping a kernel launch duplicates the launch-carrying body - so wrapper handles are only stable per phase: preprocess by deduplicated root, then re-collect the wrappers that survive before the per-wrapper passes. Rebased onto main from the buffer-normalization stack. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD
wsmoses
force-pushed
the
pb/dowhile-unroll
branch
from
August 30, 2026 12:59
d752628 to
d04ef91
Compare
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.
A rotated strided-copy loop (
k = tid; do { copy(k); } while (k < n)with the increment folded by the range analysis) arrives as anscf.whilewhose after region yields only loop-invariant values or pass-throughs of the condition-forwarded ones: every iteration past the second would repeat the second's state exactly, so a third implies the original program never terminates. Unroll it tobody(init); if (cond) body(invariant), selecting the forwarded results accordingly.This is one of the normalizations behind the
bilininteg_curlcurl_pafamily raising strict in the MFEM CUDA→xla-gpu campaign (#2968). Stacked on #3006 (basepb/buffer-normalizations) for the preprocessing-round scaffolding.Includes a lit test of the rotated strided-copy shape raising end to end.
🤖 Generated with Claude Code
https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD