From 8bd0cc1a5a5fe80fcf7ae25d00e7aea1cd2e3987 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 1 Mar 2021 11:57:19 -0800 Subject: [PATCH] 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 Part-of: --- 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 3efe709..c9572f6 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); -- 2.7.4