From d77c2a1ece36fc72a1e65d6a7ae851e0c9ee5a2f Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Fri, 13 Mar 2026 09:46:19 +0100 Subject: [PATCH] nir/opt_algebraic: take advantage of range helpers including nnan No Foz-DB changes. Reviewed-by: Alyssa Rosenzweig Part-of: --- src/compiler/nir/nir_opt_algebraic.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index b8a7f720fb9..78cbdb8b498 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -899,10 +899,6 @@ optimizations.extend([ (('flt', ('fadd(is_used_once)', a, ('fneg', b)), 0.0), ('flt', a, b)), - (('bcsel(is_only_used_as_float_nsz)', ('flt(nnan)', b, a), b, a), ('fmin(preserve_nan_inf)', a, b)), - (('bcsel(is_only_used_as_float_nsz)', ('flt(nnan)', a, b), b, a), ('fmax(preserve_nan_inf)', a, b)), - (('bcsel(is_only_used_as_float_nsz)', ('fge(nnan)', a, b), b, a), ('fmin(preserve_nan_inf)', a, b)), - (('bcsel(is_only_used_as_float_nsz)', ('fge(nnan)', b, a), b, a), ('fmax(preserve_nan_inf)', a, b)), (('bcsel(is_only_used_as_float_nsz)', ('flt', b, 'a(is_a_number)'), b, a), ('fmin(preserve_nan_inf)', a, b)), (('bcsel(is_only_used_as_float_nsz)', ('flt', 'a(is_a_number)', b), b, a), ('fmax(preserve_nan_inf)', a, b)), (('bcsel(is_only_used_as_float_nsz)', ('fge', 'a(is_a_number)', b), b, a), ('fmin(preserve_nan_inf)', a, b)), @@ -1054,10 +1050,8 @@ optimizations.extend([ # fmin(0.0, b)) while the right one is "b", so this optimization is not NaN correct. (('fmin(nsz)', ('fsat(nnan)', a), '#b(is_zero_to_one)'), ('fsat', ('fmin', a, b))), - (('fsat(nnan)', 'a(is_ge_pos_one)'), 1.0), (('fsat', 'a(is_a_number_ge_pos_one)'), 1.0), - (('fsat(nnan,nsz)', 'a(is_zero_to_one)'), ('fcanonicalize', a)), (('fsat(nsz)', 'a(is_a_number_zero_to_one)'), ('fcanonicalize', a)), # Let constant folding do its job. This can have emergent behaviour. @@ -1072,7 +1066,6 @@ optimizations.extend([ (('fmax', 'a(is_le_pos_one)', 0.0), ('fsat', a), '!options->lower_fsat'), (('fsat', ('fmax', a, 'b(is_not_positive)')), ('fsat', a)), - (('fsat', ('fmin(nnan)', a, 'b(is_ge_pos_one)')), ('fsat', a)), (('fsat', ('fmin', 'a(is_a_number)', 'b(is_ge_pos_one)')), ('fsat', a)), (('fsat', ('bcsel(is_used_once)', a, b, '#c')), ('bcsel', a, ('fsat', b), ('fsat', c))), @@ -1913,13 +1906,12 @@ optimizations.extend([ (('ftrunc', 'a(is_integral)'), a), (('fround_even', 'a(is_integral)'), a), - # fract(x) = x - floor(x), so fract(NaN) = NaN + # fract(x) = x - floor(x), so fract(NaN/Inf) = NaN (('ffract(nnan)', 'a(is_integral)'), 0.0), (('ffract', ('ffract', a)), ('ffract', a)), (('fabs', 'a(is_not_negative)'), ('fcanonicalize', a)), (('fsat', 'a(is_not_positive)'), 0.0), - (('fmin(nnan,nsz)', 'a(is_not_negative)', 1.0), ('fsat', a), '!options->lower_fsat'), (('fmin(nsz)', 'a(is_a_number_not_negative)', 1.0), ('fsat', a), '!options->lower_fsat'), # The result of the multiply must be in [-1, 0], so the result of the ffma