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.
This is a prerequisite for:
RUSTGPU_CODEGEN_ARGS=--spirt
). #940 (comment)(the link goes to my comment explanation the plan that this PR is a part of)
The problem this PR solves is that the inliner did not support "φ nodes" (
OpPhi
in SPIR-V), as they did not exist at the point where it was ran (i.e. all passes that would introduceOpPhi
s ran after the inliner).This manifested as broken
OpPhi
s, since the sources of control-flow edges (i.e. the side with the branch instruction) changed without theOpPhi
s in the destinations being updated to reflect the CFG change.But with SPIR-T, we want the speedups that come from being able run the inliner after passes that create
OpPhi
s (as the SPIR-T CFG structurizer can handleOpPhi
s just fine, unlike our existing one).More specifically, in #940, we end up with two
mem2reg
passes, trying to do as much as possible before, and the rest after, inlining (though ideally they it should be interleaved with inlining, as per EmbarkStudios/spirt#6).Thankfully most of the changes (in the big
inline_block
function) were only for readability, and the bulk of the additions just change some basic-block IDs in place, they don't do any complicated analysis or rewriting, so it felt straight-forward enough to have it in the existing inliner, instead of trying to replace it with a SPIR-T one.