diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index f790c3dc3af..b0bad82e9e6 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -946,6 +946,12 @@ optimizations.extend([ # fmin(0.0, b)) while the right one is "b", so this optimization is inexact. (('~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), + + # 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))), + # max(-min(b, a), b) -> max(abs(b), -a) # min(-max(b, a), b) -> min(-abs(b), -a) (('fmax', ('fneg', ('fmin', b, a)), b), ('fmax', ('fabs', b), ('fneg', a))),