treewide: Use nir_trim_vector more

Via Coccinelle patches

    @@
    expression a, b, c;
    @@

    -nir_channels(b, a, (1 << c) - 1)
    +nir_trim_vector(b, a, c)

    @@
    expression a, b, c;
    @@

    -nir_channels(b, a, BITFIELD_MASK(c))
    +nir_trim_vector(b, a, c)

    @@
    expression a, b;
    @@

    -nir_channels(b, a, 3)
    +nir_trim_vector(b, a, 2)

    @@
    expression a, b;
    @@

    -nir_channels(b, a, 7)
    +nir_trim_vector(b, a, 3)

Plus a fixup for pointless trimming an immediate in RADV and radeonsi.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23352>
This commit is contained in:
Alyssa Rosenzweig
2023-05-31 21:08:47 -04:00
committed by Marge Bot
parent 68eda9456f
commit 99a00e2247
46 changed files with 114 additions and 99 deletions

View File

@@ -84,7 +84,7 @@ lower_bitmap(nir_shader *shader, nir_builder *b,
tex->src[1] = nir_tex_src_for_ssa(nir_tex_src_sampler_deref,
&tex_deref->dest.ssa);
tex->src[2] = nir_tex_src_for_ssa(nir_tex_src_coord,
nir_channels(b, texcoord, (1 << tex->coord_components) - 1));
nir_trim_vector(b, texcoord, tex->coord_components));
nir_ssa_dest_init(&tex->instr, &tex->dest, 4, 32);
nir_builder_instr_insert(b, &tex->instr);