nir/algebraic: Do not generate 8- or 16-bit find_msb

The next commit will add validation to restrict this instruction (and
others) to only 32-bit or 64-bit sources.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19042>
This commit is contained in:
Ian Romanick
2022-10-24 13:26:31 -07:00
committed by Marge Bot
parent 2119ab7319
commit 2d6f48f6ef

View File

@@ -1809,6 +1809,8 @@ optimizations.extend([
(('bcsel', ('ine', 'a@32', 0), ('iadd', 31, ('ineg', ('ufind_msb_rev', a))), ('ufind_msb_rev', a)), ('ufind_msb', a), '!options->lower_find_msb_to_reverse'),
(('bcsel', ('ieq', 'a@32', 0), ('ufind_msb_rev', a), ('iadd', 31, ('ineg', ('ufind_msb_rev', a)))), ('ufind_msb', a), '!options->lower_find_msb_to_reverse'),
# This is safe. Both ufind_msb_rev and bitfield_reverse can only have
# 32-bit sources, so the transformation can only generate correct NIR.
(('find_lsb', ('bitfield_reverse', a)), ('ufind_msb_rev', a), 'options->has_find_msb_rev'),
(('ufind_msb_rev', ('bitfield_reverse', a)), ('find_lsb', a), '!options->lower_find_lsb'),
@@ -2047,10 +2049,14 @@ optimizations.extend([
(('uclz', a), ('umin', 32, ('ufind_msb_rev', a)), 'options->lower_uclz'),
(('find_lsb', 'value'),
(('find_lsb', 'value@64'),
('ufind_msb', ('iand', 'value', ('ineg', 'value'))),
'options->lower_find_lsb'),
(('find_lsb', 'value'),
('ufind_msb', ('u2u32', ('iand', 'value', ('ineg', 'value')))),
'options->lower_find_lsb'),
(('extract_i8', a, 'b@32'),
('ishr', ('ishl', a, ('imul', ('isub', 3, b), 8)), 24),
'options->lower_extract_byte'),