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@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9345>
This commit is contained in:
Eric Anholt 2021-03-01 11:57:19 -08:00 committed by Marge Bot
parent 1e5ef4c60c
commit 8bd0cc1a5a

View file

@ -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);