diff --git a/.pick_status.json b/.pick_status.json index 3217d39d82e..a30dcbadce3 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -94,7 +94,7 @@ "description": "nir/opt_algebraic: disable fsat(a + 1.0) opt if a can be NaN", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "a4a3487aae98cc83990b1c79785983b65124145f", "notes": null diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 7a9ae9b3eb4..77716f7542e 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -980,7 +980,9 @@ optimizations.extend([ (('~fmin', ('fsat', a), '#b(is_zero_to_one)'), ('fsat', ('fmin', a, b))), # If a >= 0 ... 1 + a >= 1 ... so fsat(1 + a) = 1 - (('fsat', ('fadd', 1.0, 'a(is_ge_zero)')), 1.0), + # But 1 + NaN is NaN and fsat(NaN) = 0. + (('~fsat', ('fadd', 1.0, 'a(is_not_negative)')), 1.0), + (('fsat', ('fadd', 1.0, 'a(is_a_number_not_negative)')), 1.0), # Let constant folding do its job. This can have emergent behaviour. (('fneg', ('bcsel(is_used_once)', a, '#b', '#c')), ('bcsel', a, ('fneg', b), ('fneg', c))),