Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spv/lift: use loop body entry (instead of exit), as the "continue" ta…
…rget. (#10) As we have no `break` edges out of SPIR-T loop bodies, any point in the loop body (not nested in another selection/loop) is a valid "continue" target, and we can spare a block by making *the whole body* that. In [WGSL loops](https://gpuweb.github.io/gpuweb/wgsl/#loop-statement), this corresponds to moving the rest of the loop body (*not* using `break`/`continue`) into the `continuing {...}` block. <sub>(but examples are hard because `break if` isn't implemented yet in Naga, and our `do`-`while`-style loops use SPIR-V "conditional back-edges" which in WGSL *require* `break if` - see gfx-rs/naga#1977 (comment) for more details/context)</sub> For `tests/data/for-loop.wgsl.spvasm` (after `spirv-as` -> `spv-lower-link-lift` -> `spirv-dis`), the change is: ```diff @@ -25,5 +25,5 @@ %22 = OpLabel - %13 = OpPhi %int %int_1 %21 %16 %27 - %14 = OpPhi %int %int_1 %21 %17 %27 - OpLoopMerge %28 %27 None + %13 = OpPhi %int %int_1 %21 %16 %26 + %14 = OpPhi %int %int_1 %21 %17 %26 + OpLoopMerge %28 %23 None OpBranch %23 @@ -44,4 +44,2 @@ %17 = OpPhi %int %20 %24 %11 %25 - OpBranch %27 - %27 = OpLabel OpBranchConditional %15 %22 %28 ``` <sub>(on the "after" side I had to use `sed 's/%27/%28/g'` on to make the diff more readable wrt renumbering)</sub>
- Loading branch information