From: Rob Clark Date: Mon, 8 Jun 2020 16:52:28 +0000 (-0700) Subject: nir/validate: validate intr->num_components X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=167fa2887f0928042dcb21bbc2fa89ae9a29897d;p=mesa.git nir/validate: validate intr->num_components Validate that num_components is only set for vectorized instructions, to prevent other nir passes or driver backends from mistakenly relying on num_components for non-vectorized instructions. Signed-off-by: Rob Clark Reviewed-by: Jason Ekstrand Part-of: --- diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index e9fc6150c24..ad76b94c9a9 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -514,6 +514,21 @@ validate_deref_instr(nir_deref_instr *instr, validate_state *state) } } +static bool +vectorized_intrinsic(nir_intrinsic_instr *intr) +{ + const nir_intrinsic_info *info = &nir_intrinsic_infos[intr->intrinsic]; + + if (info->dest_components == 0) + return true; + + for (unsigned i = 0; i < info->num_srcs; i++) + if (info->src_components[i] == 0) + return true; + + return false; +} + static void validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state) { @@ -640,6 +655,9 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state) validate_dest(&instr->dest, state, dest_bit_size, components_written); } + + if (!vectorized_intrinsic(instr)) + validate_assert(state, instr->num_components == 0); } static void