Raising: expand buffer-yielding branches into their accesses - #3007
Open
wsmoses wants to merge 1 commit into
Open
Raising: expand buffer-yielding branches into their accesses#3007wsmoses wants to merge 1 commit into
wsmoses wants to merge 1 commit into
Conversation
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
Member
Quoting myself from JuliaMath/SpecialFunctions.jl#552 (comment)
Edit: switched to a real stack. |
This was referenced Aug 28, 2026
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.
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 anarith.selectof buffers, anscf.ifyielding a pointer whose arms compute geps, or anaffine.ifyielding 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_selectgolden 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