Skip to content

Raising: unroll invariant-yield do-whiles - #3013

Open
wsmoses wants to merge 1 commit into
mainfrom
pb/dowhile-unroll
Open

Raising: unroll invariant-yield do-whiles#3013
wsmoses wants to merge 1 commit into
mainfrom
pb/dowhile-unroll

Conversation

@wsmoses

@wsmoses wsmoses commented Aug 28, 2026

Copy link
Copy Markdown
Member

A rotated strided-copy loop (k = tid; do { copy(k); } while (k < n) with the increment folded by the range analysis) arrives as an scf.while whose 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 to body(init); if (cond) body(invariant), selecting the forwarded results accordingly.

This is one of the normalizations behind the bilininteg_curlcurl_pa family raising strict in the MFEM CUDA→xla-gpu campaign (#2968). Stacked on #3006 (base pb/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

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
wsmoses changed the base branch from pb/buffer-normalizations to main August 30, 2026 12:59
@wsmoses
wsmoses force-pushed the pb/dowhile-unroll branch from d752628 to d04ef91 Compare August 30, 2026 12:59
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.

1 participant