nir/lower_bit_size: optimize usub_sat lowering

The result should never be larger than uint_max. This doesn't need a
special path.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19473>
This commit is contained in:
Rhys Perry 2022-11-03 13:05:41 +00:00 committed by Marge Bot
parent e19584db2b
commit 8a4f9a874b

View file

@ -94,7 +94,7 @@ lower_alu_instr(nir_builder *bld, nir_alu_instr *alu, unsigned bit_size)
lowered_dst = nir_iclamp(bld, lowered_dst,
nir_imm_intN_t(bld, int_min, bit_size),
nir_imm_intN_t(bld, int_max, bit_size));
} else if (op == nir_op_uadd_sat || op == nir_op_usub_sat) {
} else if (op == nir_op_uadd_sat) {
const uint64_t uint_max = u_uintN_max(dst_bit_size);
lowered_dst = nir_umin(bld, lowered_dst,