diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index de71167024a..7aae5cf4943 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -731,6 +731,13 @@ optimizations.extend([ # 0 < fsat(NaN) -> 0 < 0 -> false, and 0 < NaN -> false. (('flt', 0.0, ('fsat(is_used_once)', a)), ('flt', 0.0, a)), + (('bcsel(is_only_used_as_float)', ('feq', a, 'b(is_not_zero)'), b, a), a), + (('bcsel(is_only_used_as_float)', ('fneu', a, 'b(is_not_zero)'), a, b), a), + (('bcsel', ignore_exact('feq', a, 0), 0, ('fsat', ('fmul', a, 'b(is_a_number)'))), ('fsat!', ('fmul', a, b))), + (('bcsel', ignore_exact('fneu', a, 0), ('fsat', ('fmul', a, 'b(is_a_number)')), 0), ('fsat!', ('fmul', a, b))), + (('bcsel', ignore_exact('feq', a, 0), b, ('fadd', a, 'b(is_not_zero)')), ('fadd', a, b)), + (('bcsel', ignore_exact('fneu', a, 0), ('fadd', a, 'b(is_not_zero)'), b), ('fadd', a, b)), + # 0.0 >= b2f(a) # b2f(a) <= 0.0 # b2f(a) == 0.0 because b2f(a) can only be 0 or 1