Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cfg: use Tarjan's SCC algorithm to get "minimal loops" (instead of "maximal"). #48

Merged
merged 3 commits into from
Oct 5, 2023

Conversation

eddyb
Copy link
Contributor

@eddyb eddyb commented Sep 28, 2023

Quoting from the comment I added to the code:

This analysis was added to because of two observations wrt "reconvergence":

  1. syntactic loops (from some high-level language), when truly structured
    (i.e. only using while/do-while exit conditions, not break etc.),
    always map to "minimal loops" on a CFG, as the only loop exit edge is
    built-in, and no part of the syntactic "loop body" can be its successor
  2. more pragmatically, compiling shader languages to SPIR-V seems to (almost?)
    always either fully preserve syntactic loops (via SPIR-V OpLoopMerge),
    or structurize CFGs in a way that produces "minimal loops", which can
    be misleading with explicit breaks (moving user code from just before
    the break to after the loop), but is less impactful than "maximal loops"

See also:

@eddyb eddyb marked this pull request as ready for review October 5, 2023 10:28
@eddyb eddyb enabled auto-merge October 5, 2023 10:30
@eddyb eddyb added this pull request to the merge queue Oct 5, 2023
Merged via the queue into main with commit 521c241 Oct 5, 2023
6 checks passed
@eddyb eddyb deleted the scc-min-loops branch October 5, 2023 11:01
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