From 07ba9335ae26e2ca81b9bc2a5f88e53f708b91d1 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 18 Nov 2024 14:20:07 -0400 Subject: [PATCH] nir/conversion_builder: avoid redundant uint->uint clamp algebraic will clean up but there's no reason to generate it. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Georg Lehmann Part-of: --- src/compiler/nir/nir_conversion_builder.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_conversion_builder.h b/src/compiler/nir/nir_conversion_builder.h index 1600cb1442b..680217a5abe 100644 --- a/src/compiler/nir/nir_conversion_builder.h +++ b/src/compiler/nir/nir_conversion_builder.h @@ -269,7 +269,10 @@ nir_get_clamp_limits(nir_builder *b, case nir_type_uint: { uint64_t uhigh = dest_bit_size == 64 ? ~0ull : (1ull << dest_bit_size) - 1; if (src_base_type != nir_type_float) { - *low = nir_imm_intN_t(b, 0, src_bit_size); + /* for uint->uint conversions, no need to clamp negatives */ + if (src_base_type != nir_type_uint) + *low = nir_imm_intN_t(b, 0, src_bit_size); + if (src_base_type == nir_type_uint || src_bit_size > dest_bit_size) *high = nir_imm_intN_t(b, uhigh, src_bit_size); } else {