mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 00:38:48 +02:00
nir: Fix constant folding for iadd_sat
Use INT_MIN instead of INT_MAX for underflow. Fixes:cc4b50b023("nir/opcodes: use u_overflow to fix incorrect checks") Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Pierre-Eric Pelloux-Prayer <pelloux@gmail.com> (cherry picked from commitda57fbfb07) Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40359>
This commit is contained in:
parent
725626858d
commit
8355670805
3 changed files with 4 additions and 4 deletions
|
|
@ -1864,7 +1864,7 @@
|
|||
"description": "nir: Fix constant folding for iadd_sat",
|
||||
"nominated": true,
|
||||
"nomination_type": 2,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "cc4b50b023c227e2dbc909cb8332bce027261764",
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -696,7 +696,7 @@ if (nir_is_rounding_mode_rtz(execution_mode, bit_size)) {
|
|||
binop("iadd", tint, _2src_commutative + associative, "(uint64_t)src0 + (uint64_t)src1")
|
||||
binop("iadd_sat", tint, _2src_commutative, """
|
||||
util_add_check_overflow({dest_type}, src0, src1) ?
|
||||
(src1 < 0 ? u_intN_max(bit_size) : u_uintN_max(bit_size)) : (src0 + src1)
|
||||
(src1 < 0 ? u_intN_min(bit_size) : u_intN_max(bit_size)) : (src0 + src1)
|
||||
""", "", True)
|
||||
binop("uadd_sat", tuint, _2src_commutative,
|
||||
"util_add_check_overflow({dest_type}, src0, src1) ? u_uintN_max(sizeof(src0) * 8) : (src0 + src1)",
|
||||
|
|
|
|||
|
|
@ -2507,7 +2507,7 @@ optimizations.extend([
|
|||
('ior', ('ior', ('ilt', a, 0), ('ilt', b, 0)), ('ige', ('iadd', a, b), 0)),
|
||||
('iadd', a, b),
|
||||
0x7fffffffffffffff)),
|
||||
'(options->lower_int64_options & nir_lower_iadd_sat64) != 0', TestStatus.XFAIL),
|
||||
'(options->lower_int64_options & nir_lower_iadd_sat64) != 0'),
|
||||
|
||||
# int64_t sum = a - b;
|
||||
#
|
||||
|
|
@ -2936,7 +2936,7 @@ for bit_size in [8, 16, 32, 64]:
|
|||
optimizations += [
|
||||
(('iadd_sat@' + str(bit_size), a, b),
|
||||
('bcsel', ('ige', b, 1), ('bcsel', ('ilt', ('iadd', a, b), a), intmax, ('iadd', a, b)),
|
||||
('bcsel', ('ilt', a, ('iadd', a, b)), intmin, ('iadd', a, b))), 'options->lower_iadd_sat', TestStatus.XFAIL if bit_size in [8, 64] else TestStatus.PASS),
|
||||
('bcsel', ('ilt', a, ('iadd', a, b)), intmin, ('iadd', a, b))), 'options->lower_iadd_sat'),
|
||||
(('isub_sat@' + str(bit_size), a, b),
|
||||
('bcsel', ('ilt', b, 0), ('bcsel', ('ilt', ('isub', a, b), a), intmax, ('isub', a, b)),
|
||||
('bcsel', ('ilt', a, ('isub', a, b)), intmin, ('isub', a, b))), 'options->lower_iadd_sat'),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue