nir: Optimize unpacking 16 bit values that were originally packed

I was seeing u2u64 still in my final shader after pack/unpack were
lowered, which sounds to me like some other optimizations are missing
for detecting the post-lowering pack/unpack patterns, but let's at
least add some patterns for the simple cases.

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23173>
This commit is contained in:
Jesse Natalie 2023-05-23 15:49:38 -07:00 committed by Marge Bot
parent 663d957480
commit fba82797d7

View file

@ -1601,6 +1601,10 @@ optimizations.extend([
(('pack_64_2x32', ('unpack_64_2x32', a)), a),
(('pack_double_2x32_dxil', ('unpack_double_2x32_dxil', a)), a),
(('unpack_64_4x16', ('pack_64_4x16', a)), a),
(('unpack_64_4x16', ('pack_64_2x32', ('vec2', ('pack_32_2x16_split', a, b), ('pack_32_2x16_split', c, d)))), ('vec4', a, b, c, d)),
(('unpack_64_4x16', ('pack_64_2x32_split', ('pack_32_2x16_split', a, b), ('pack_32_2x16_split', c, d))), ('vec4', a, b, c, d)),
# Comparing two halves of an unpack separately. While this optimization
# should be correct for non-constant values, it's less obvious that it's
# useful in that case. For constant values, the pack will fold and we're