From 9a225415e334d77be687f4ad8e803f9e3748866f Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Tue, 29 Nov 2022 12:48:38 -0600 Subject: [PATCH] nir/builder: Short-circuit in nir_type_convert if no conversion happens MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Emma Anholt Reviewed-by: Timur Kristóf Part-of: --- src/compiler/nir/nir_builder.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/nir/nir_builder.c b/src/compiler/nir/nir_builder.c index 44dbbbd55fd..b35776b2a67 100644 --- a/src/compiler/nir/nir_builder.c +++ b/src/compiler/nir/nir_builder.c @@ -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); }