nir/lower_bit_size: Support add_sat and sub_sat
authorIan Romanick <ian.d.romanick@intel.com>
Thu, 29 Jul 2021 01:16:24 +0000 (18:16 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 24 Aug 2021 19:58:57 +0000 (19:58 +0000)
commit7d8bf7c167d962421d1f8af451b82188357926af
treee71e827df287cc36ce0d1fa4ceaf04a117e27903
parent8503cab2e0032dd4d4bd1548919d3c359db82547
nir/lower_bit_size: Support add_sat and sub_sat

Without this, lowered saturating ALU instructions would only clamp to
the range of the new type instead of the range of the old type.

v2: Use nir_iclamp.  Suggested by Jason. Use new
u_{int,uint}N_{min,max}() helpers.

Fixes: 090e2824079 ("nir: Add a saturated unsigned integer add opcode")
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12142>
src/compiler/nir/nir_lower_bit_size.c