From 0b69aca0e823065491073748d80eca326af00bc0 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 17 Dec 2025 12:35:22 -0800 Subject: [PATCH 1/2] nir/algebraic: Add missing f on F-strings Without this, nir_algebraic.py was treating "f2i{int_sz}_sat" as the literal opcode name when it should have been "f2i8_sat" or similar. Fixes: c49d6e04808 ("nir/algebraic: Elide range clamping of f2u sources") --- src/compiler/nir/nir_opt_algebraic.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index c646eb43c4f..6912377f887 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -3680,16 +3680,16 @@ for int_sz in (8, 16, 32): late_optimizations.extend([ # This requires is_a_number because f2i_sat(NaN) is zero, but # fmax(intmin, NaN) is intmin. - ((f'f2i{int_sz}', ('fmax', f'a@{float_sz}(is_a_number)', intmin)), ('f2i{int_sz}_sat', a), 'options->has_f2i_sat'), + ((f'f2i{int_sz}', ('fmax', f'a@{float_sz}(is_a_number)', intmin)), (f'f2i{int_sz}_sat', a), 'options->has_f2i_sat'), - ((f'f2i{int_sz}', ('fmin', f'a@{float_sz}(is_a_number)', intmax)), ('f2i{int_sz}_sat', a), 'options->has_f2i_sat'), + ((f'f2i{int_sz}', ('fmin', f'a@{float_sz}(is_a_number)', intmax)), (f'f2i{int_sz}_sat', a), 'options->has_f2i_sat'), ((f'f2u{int_sz}', ('fmin', f'a@{float_sz}(is_a_number)', uintmax)), (f'f2u{int_sz}_sat', a), 'options->has_f2u_sat'), ]) late_optimizations.extend([ # This does not require is_a_number because both f2u_sat(NaN) and # fmax(NaN, 0) are zero. - ((f'f2u{int_sz}', ('fmax', f'a@{float_sz}', 0.0)), ('f2u{int_sz}_sat', a), 'options->has_f2u_sat'), + ((f'f2u{int_sz}', ('fmax', f'a@{float_sz}', 0.0)), (f'f2u{int_sz}_sat', a), 'options->has_f2u_sat'), ((f'f2u{int_sz}', ('ftrunc', f'a@{float_sz}')), (f'f2u{int_sz}_sat', a), 'options->has_f2u_sat'), From dbdcdb2e38072839d428fe5067282bb0b540f978 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 17 Dec 2025 12:37:36 -0800 Subject: [PATCH 2/2] nir/algebraic: Detect missing f on F-strings Missing f in other cases seems to be caught either elsewhere in the script or by the C compiler. Fixes: c49d6e04808 ("nir/algebraic: Elide range clamping of f2u sources") --- src/compiler/nir/nir_algebraic.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compiler/nir/nir_algebraic.py b/src/compiler/nir/nir_algebraic.py index 5ead743c8c3..1f8e643cfb6 100644 --- a/src/compiler/nir/nir_algebraic.py +++ b/src/compiler/nir/nir_algebraic.py @@ -107,6 +107,9 @@ class SearchExpression(object): self.sources = expr[1:] self.ignore_exact = False + assert '{' not in self.opcode, \ + 'Malformed opcode name \"{}\".'.format(self.opcode) + @staticmethod def create(val): if isinstance(val, tuple):