Mesa (master): nir/vec_to_movs: Don't generate MOVs for undef channels.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Mar 3 01:07:41 UTC 2021


Module: Mesa
Branch: master
Commit: 8bd0cc1a5a5fe80fcf7ae25d00e7aea1cd2e3987
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8bd0cc1a5a5fe80fcf7ae25d00e7aea1cd2e3987

Author: Eric Anholt <eric at anholt.net>
Date:   Mon Mar  1 11:57:19 2021 -0800

nir/vec_to_movs: Don't generate MOVs for undef channels.

This appeared in softpipe's image operations, since NIR always uses
4-component values for the coords, while the GLSL IR only has 2 components
for a 2D image (for example).
arb_shader_image_load_store-shader-mem-barrier (which times out in CI and
spends its time inside of tgsi_exec) was spending 4/51 of its instructions
on moving these undefs around.

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9345>

---

 src/compiler/nir/nir_lower_vec_to_movs.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/compiler/nir/nir_lower_vec_to_movs.c b/src/compiler/nir/nir_lower_vec_to_movs.c
index 3efe709b39f..c9572f604f8 100644
--- a/src/compiler/nir/nir_lower_vec_to_movs.c
+++ b/src/compiler/nir/nir_lower_vec_to_movs.c
@@ -63,6 +63,10 @@ insert_mov(nir_alu_instr *vec, unsigned start_idx, nir_shader *shader)
 {
    assert(start_idx < nir_op_infos[vec->op].num_inputs);
 
+   /* No sense generating a MOV from undef, we can just leave the dst channel undef. */
+   if (nir_src_is_undef(vec->src[start_idx].src))
+      return 1 << start_idx;
+
    nir_alu_instr *mov = nir_alu_instr_create(shader, nir_op_mov);
    nir_alu_src_copy(&mov->src[0], &vec->src[start_idx], mov);
    nir_alu_dest_copy(&mov->dest, &vec->dest, mov);



More information about the mesa-commit mailing list