nir/algebraic: eliminate pack+unpack and unpack+pack pairs

A new NIR shader for AMD drivers will need this.

Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29233>
This commit is contained in:
Marek Olšák 2024-05-01 15:22:55 -04:00 committed by Marge Bot
parent 681acde6d3
commit b4bd380704

View file

@ -1744,6 +1744,16 @@ optimizations.extend([
(('ibfe', a, 0, 16), ('extract_i16', a, 0), '!options->lower_extract_word'),
(('ibfe', a, 16, 16), ('extract_i16', a, 1), '!options->lower_extract_word'),
# Collapse nop packing.
(('unpack_32_4x8', ('pack_32_4x8', a)), a),
(('unpack_32_2x16', ('pack_32_2x16', a)), a),
(('unpack_64_4x16', ('pack_64_4x16', a)), a),
(('unpack_64_2x32', ('pack_64_2x32', a)), a),
(('pack_32_4x8', ('unpack_32_4x8', a)), a),
(('pack_32_2x16', ('unpack_32_2x16', a)), a),
(('pack_64_4x16', ('unpack_64_4x16', a)), a),
(('pack_64_2x32', ('unpack_64_2x32', a)), a),
# Packing a u8vec4 to write to an SSBO.
(('ior', ('ishl', ('u2u32', 'a@8'), 24), ('ior', ('ishl', ('u2u32', 'b@8'), 16), ('ior', ('ishl', ('u2u32', 'c@8'), 8), ('u2u32', 'd@8')))),
('pack_32_4x8', ('vec4', d, c, b, a)), 'options->has_pack_32_4x8'),