Skip to content

Raising: expand buffer-yielding branches into their accesses - #3007

Open
wsmoses wants to merge 1 commit into
pb/buffer-normalizationsfrom
pb/buffer-branches
Open

Raising: expand buffer-yielding branches into their accesses#3007
wsmoses wants to merge 1 commit into
pb/buffer-normalizationsfrom
pb/buffer-branches

Conversation

@wsmoses

@wsmoses wsmoses commented Aug 28, 2026

Copy link
Copy Markdown
Member

Stacks on #3006.

mfem's coefficient ternary (const_coeff ? c(0,0,0) : c(i,j,e)) arrives at the raising as a branch yielding a pointer or a whole memref — as an arith.select of buffers, an scf.if yielding a pointer whose arms compute geps, or an affine.if yielding a memref. No tensor value can stand for the yielded buffer, so each access is pushed down into a clone of the branch: only scalars cross the yield and the branch raises as a select. Arms may contain loads (reads are idempotent and clone safely per pushed-down access); branches whose buffer results die are rebuilt without them when scalar yields keep the branch alive.

The existing raise_buffer_select golden changes from a whole-tensor select to a per-access select — equivalent, and the expansion also covers the cases the whole-buffer path had to reject (a store through the selected buffer).

Part of #2968.

🤖 Generated with Claude Code

https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD

mfem's coefficient ternary (const_coeff ? c(0,0,0) : c(i,j,e)) arrives
as a branch yielding a pointer or whole memref - as an arith.select of
buffers, an scf.if yielding a pointer whose arms compute geps, or an
affine.if yielding a memref. No tensor value can stand for the yielded
buffer, so push each access down into a clone of the branch: only
scalars cross the yield and the branch raises as a select. Arms may
contain loads (reads are idempotent and clone safely); branches also
rebuild without dead buffer results when scalars keep them alive.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD
@giordano

giordano commented Aug 28, 2026

Copy link
Copy Markdown
Member

Stacks on #3006.

Quoting myself from JuliaMath/SpecialFunctions.jl#552 (comment)

Claude loves to talk about stacking PRs, but not actually stacking them

Edit: switched to a real stack.

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