Spec version: Version 1.5, Revision 5, Unified January 7, 2021
In relation to switch, the spec says (2.11, page 29):
a case construct: the blocks dominated by an OpSwitch Target or Default (this construct is only defined for those OpSwitch Target or Default that are not equal to the OpSwitch’s corresponding merge block)
It also says:
a branch to an outer OpSwitch merge block is ...
However, the spec does not say what the merge block associated with an OpSwitch instruction is.
If OpSwitch were required to only appear as the terminator of a header block then the merge block could be defined to be the merge associated with the header block.
However, spirv-val accepts fragments of SPIR-V like this one:
Spec version: Version 1.5, Revision 5, Unified January 7, 2021
In relation to switch, the spec says (2.11, page 29):
It also says:
However, the spec does not say what the merge block associated with an OpSwitch instruction is.
If OpSwitch were required to only appear as the terminator of a header block then the merge block could be defined to be the merge associated with the header block.
However, spirv-val accepts fragments of SPIR-V like this one:
Block
%7
end withOpSwitch
, but it is not a header block.The CFG looks like this:
You can see that node 7 ends with
OpSwitch
because it has 3 outgoing edges.