nir: reuse nir_component_mask() where it makes sense
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Tue, 7 Mar 2023 11:09:43 +0000 (13:09 +0200)
committerMarge Bot <emma+marge@anholt.net>
Wed, 5 Apr 2023 12:32:56 +0000 (12:32 +0000)
Avoiding local bit field manipulations.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21853>

src/compiler/nir/nir_builder.c
src/compiler/nir/nir_validate.c

index 8a25316..5db10dd 100644 (file)
@@ -117,7 +117,7 @@ nir_builder_alu_instr_finish_and_insert(nir_builder *build, nir_alu_instr *instr
 
    nir_ssa_dest_init(&instr->instr, &instr->dest.dest, num_components,
                      bit_size, NULL);
-   instr->dest.write_mask = (1 << num_components) - 1;
+   instr->dest.write_mask = nir_component_mask(num_components);
 
    nir_builder_instr_insert(build, &instr->instr);
 
@@ -338,7 +338,7 @@ nir_vec_scalars(nir_builder *build, nir_ssa_scalar *comp, unsigned num_component
     */
    nir_ssa_dest_init(&instr->instr, &instr->dest.dest, num_components,
                      comp[0].def->bit_size, NULL);
-   instr->dest.write_mask = (1 << num_components) - 1;
+   instr->dest.write_mask = nir_component_mask(num_components);
 
    nir_builder_instr_insert(build, &instr->instr);
 
index 40d7829..8edb1cf 100644 (file)
@@ -349,7 +349,7 @@ validate_alu_dest(nir_alu_instr *instr, validate_state *state)
     * validate that the instruction doesn't write to components not in the
     * register/SSA value
     */
-   validate_assert(state, !(dest->write_mask & ~((1 << dest_size) - 1)));
+   validate_assert(state, !(dest->write_mask & ~nir_component_mask(dest_size)));
 
    /* validate that saturate is only ever used on instructions with
     * destinations of type float