nir/builder: Short-circuit in nir_type_convert if no conversion happens

If both types are the same or both are integer types with the same bit
size, no actual conversion happens and nir_type_conversion_op() will
return nir_op_mov.  In this case, there's no point in emitting the move
and we can just return src instead.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20067>
This commit is contained in:
Jason Ekstrand 2022-11-29 12:48:38 -06:00 committed by Marge Bot
parent c5fbcab803
commit 9a225415e3

View file

@ -445,6 +445,8 @@ nir_type_convert(nir_builder *b,
nir_op opcode =
nir_type_conversion_op(src_type, dest_type, nir_rounding_mode_undef);
if (opcode == nir_op_mov)
return src;
return nir_build_alu(b, opcode, src, NULL, NULL, NULL);
}