SPIR-V's OpKill is a control-flow instruction but NIR's discard is not.
Therefore, it can be valid SPIR-V to have
if (...) {
foo = /* something */
} else {
discard;
}
use(foo);
without any phi between the definition of foo and its use. This is not
true in NIR, however, because NIR's discard isn't considered
control-flow. Arguably, this is a NIR bug but making discard control-
flow is a very deep change that can have serious ans subtle
side-effects. The easier thing to do is just fix up the SSA in case we
have an OpKill which might have gotten us into the above case.
Fixes dEQP-VK.graphicsfuzz.vectors-and-discard-in-function with the new
NIR dominance validation pass enabled.
Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5288>
return NULL;
case SpvOpKill:
+ b->has_kill = true;
block->branch_type = vtn_branch_type_discard;
return NULL;
* but instructions in the continue may use SSA defs in the loop body.
* Therefore, we need to repair SSA to insert the needed phi nodes.
*/
- if (b->has_loop_continue)
+ if (b->has_loop_continue || b->has_kill)
nir_repair_ssa_impl(func->impl);
func->emitted = true;
unsigned func_param_idx;
bool has_loop_continue;
+ bool has_kill;
/* false by default, set to true by the ContractionOff execution mode */
bool exact;