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 <alyssa@rosenzweig.io>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32208>
This commit is contained in:
Alyssa Rosenzweig 2024-11-18 14:20:07 -04:00 committed by Marge Bot
parent 76927a3b43
commit 07ba9335ae

View File

@ -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 {