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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39369>
This commit is contained in:
Emma Anholt 2026-01-20 09:55:00 -08:00 committed by Marge Bot
parent e5a9eae2b5
commit cdec063d37

View file

@ -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