Skip to content

spv/lower + cfgssa speedups (useful when loading massive SPIR-V samples).#35

Draft
eddyb wants to merge 2 commits intoeddyb/var-iofrom
eddyb/cfgssa-speedups
Draft

spv/lower + cfgssa speedups (useful when loading massive SPIR-V samples).#35
eddyb wants to merge 2 commits intoeddyb/var-iofrom
eddyb/cfgssa-speedups

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):


In order to avoid assuming SSA dominance rules, spv::lower (SPIR-V -> SPIR-T) uses a helper cfgssa module to compute the full set of "cross-block uses" (i.e. values used from blocks other than the ones they were defined in), and introduce additional dataflow as necessary - akin to always handling inter-BB dataflow via phis/"BB arguments".

While this strategy has helped SPIR-T soundly implement "minimal loop" structurization (resulting in e.g. necessary OpPhis at the end of SPIR-V -> SPIR-T -> SPIR-V, that didn't exist in the original unstructured SPIR-V), it doesn't come for free, and the conservatively correct dataflow can be excessive.

This PR contains two small improvements (that mainly help with large single-function SPIR-V):

  • bypass the extra explicit dataflow for values defined in the entry block (such as OpVariables)
  • an extra level of sparseness in cfgssa's tracking bitsets (mainly to lower transient memory usage)

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