Cache the block order and skip unchanged nested regions in ConstantPropagation - #2476
Queued
ThrudPrimrose wants to merge 1 commit into
Queued
Cache the block order and skip unchanged nested regions in ConstantPropagation#2476ThrudPrimrose wants to merge 1 commit into
ThrudPrimrose wants to merge 1 commit into
Conversation
…opagation Constant collection is a fixpoint over each control flow region, and it recursed into nested regions from inside the fixpoint loop. So every sweep of every region re-ran blockorder_topological_sort, which computes immediate dominators and branch merges, and a region nested d levels deep was re-analysed on every sweep at every enclosing level. Neither is needed. The CFG does not change while constants are being collected, so the block order is the same on every sweep. What a nested region computes is a function of its 'in' constants alone, so re-collecting it with unchanged inputs recomputes the same fixpoint. Cache the block order per region, and record the 'in' constants each nested region was last collected with so it is re-collected only when those change. The transfer and meet rules are untouched.
acalotoiu
added this pull request to the merge queue
Aug 4, 2026
Any commits made after this event will not be merged.
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.
Constant collection is a fixpoint over each control flow region, and it recursed into nested regions
from inside the fixpoint loop. So every sweep of every region re-ran
blockorder_topological_sort,which computes immediate dominators and branch merges over the region, and a region nested
dlevelsdeep was re-analysed on every sweep at every enclosing level.
Neither is needed. The CFG does not change while constants are being collected, so the block order is
the same on every sweep and can be cached; and a nested region is a function of its incoming
constants, so an unchanged input reaches the same fixpoint and does not need re-collecting. The
transfer and meet rules are untouched — this only changes the schedule.
Measured on the CloudSC kernel, parsed once with
to_sdfg(simplify=False)and deepcopied fresh forevery timed run, arms interleaved rep by rep. Median (min–max), 5 reps:
The box was not idle, so treat the absolute times as loaded; within-arm spread is under 5% and every
rep interleaves the arms, so the ratios hold.
Old and new produce identical output: the same propagated-symbol set, and equal SDFGs across symbols,
data descriptors, compile-time constants, blocks, interstate conditions and assignments, dataflow
nodes, tasklet code, memlets, loop headers and conditional branches.
Split out of #2470 so the scheduling change can be reviewed and merged on its own; the CloudSC corpus,
its integration tests and the timing budget stay there and rebase onto this.