nir_opt_algebraic: Add a couple optimizations for lowered unpack(pack())

I noticed some unnecessary 64-bit ints in shaders that were using doubles.
Perhaps there's a different missing optimization that should run on the
actual pack/unpack instructions before they're lowered, or maybe I'm just
lowering them too early, but these seem simple enough that we might want
them even for hand-rolled pack/unpack pairs.

Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27314>
This commit is contained in:
Jesse Natalie 2024-01-26 14:20:55 -08:00 committed by Marge Bot
parent a24ed1146d
commit 894f7f4387
1 changed files with 4 additions and 0 deletions

View File

@ -1800,6 +1800,10 @@ optimizations.extend([
# Reduce intermediate precision with int64.
(('u2u32', ('iadd(is_used_once)', 'a@64', b)),
('iadd', ('u2u32', a), ('u2u32', b))),
# Lowered pack followed by lowered unpack, for the high bits
(('u2u32', ('ushr', ('ior', ('ishl', a, 32), ('u2u64', b)), 32)), ('u2u32', a)),
(('u2u16', ('ushr', ('ior', ('ishl', a, 16), ('u2u32', b)), 16)), ('u2u16', a)),
])
# After the ('extract_u8', a, 0) pattern, above, triggers, there will be