Skip to content

WIP: hermetic (on the output side) loops.#36

Draft
eddyb wants to merge 1 commit intoeddyb/cfgssa-speedupsfrom
eddyb/output-hermetic-loops
Draft

WIP: hermetic (on the output side) loops.#36
eddyb wants to merge 1 commit intoeddyb/cfgssa-speedupsfrom
eddyb/output-hermetic-loops

Conversation

@eddyb
Copy link
Copy Markdown
Member

@eddyb eddyb commented Apr 22, 2026

Note: this PR is a draft to avoid accidental merging onto its "base" branch (used as a form of ad-hoc PR stacking), and will remain as such, until its "base" branch can be set to main, i.e. all prerequisite PRs will have landed, up to and including this PR (whose branch is the "base" of this one):


NodeKind::Select (if-else/switch) already requires plumbing any values computed in a case, through that case's region outputs, so they can be accessed from the parent region (through the node's outputs).

However, before this PR, NodeKind::Loop operated more like SSA dominance rules, and values defined by its body region, could be accessed outside of the loop.

This PR changes loops to be similarly hermetic, and, similarly to RVSDG, plumb any values needed outside the loop, through the loop body's region outputs.

One example of where this change helps simplify/localize reasoning, is when replacing a node's outputs.
When all regions and nodes are ("output-side") hermetic, only the parent region of a node needs to be traversed, in order to find all uses of that node's outputs - and if they're being "exported" from the region, they will have to be used in the region's outputs, but only there will the original Vars be used directly.


TODO: improve pretty-printing, consider using Option<Var> instead of Var in region inputs/node outputs (in order to indicate a slot being taken up, but not actually actively used.

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