From cdec063d372525c9962db73b1016ffc5315bde75 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Tue, 20 Jan 2026 09:55:00 -0800 Subject: [PATCH] nir/opt_algebraic: Fix a bit of imad24_ir3's optimization. The mul is 24-bit sign-extended, so in simplifying we should retain that. If nothing else, this keeps us on the happy path of mul24s. I didn't fix the other broken pattern, since it's not really part of this MR. Part-of: --- src/compiler/nir/nir_opt_algebraic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 2e28512f2cd..b308a54bce9 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -2805,12 +2805,12 @@ optimizations.extend([ (('imad24_ir3', a, b, 0), ('imul24', a, b)), (('imad24_ir3', a, 0, c), (c)), - (('imad24_ir3', a, 1, c), ('iadd', a, c)), + (('imad24_ir3', a, 1, c), ('iadd', a, c)), # this is not correct -- a's sign extension gets dropped. # if first two srcs are const, crack apart the imad so constant folding # can clean up the imul: # TODO ffma should probably get a similar rule: - (('imad24_ir3', '#a', '#b', c), ('iadd', ('imul', a, b), c)), + (('imad24_ir3', '#a', '#b', c), ('iadd', ('imul24', a, b), c)), # These will turn 24b address/offset calc back into 32b shifts, but # it should be safe to get back some of the bits of precision that we