Commit 4eeb49ea authored by Daniel Schürmann's avatar Daniel Schürmann Committed by Daniel Schürmann

nir/algebraic: Remove unnecessary iand of [iu]bfe and bfm sources

The [iu]bfe and bfm instructions are defined to only use the five
least significant bits.
This optimizes a common pattern from D3D -> SPIR-V translation.
Reviewed-by: Connor Abbott's avatarConnor Abbott <cwabbott0@gmail.com>
parent 165b7f3a
...@@ -809,6 +809,14 @@ optimizations.extend([ ...@@ -809,6 +809,14 @@ optimizations.extend([
('ubfe', 'value', 'offset', 'bits')), ('ubfe', 'value', 'offset', 'bits')),
'options->lower_bitfield_extract'), 'options->lower_bitfield_extract'),
# Note that these opcodes are defined to only use the five least significant bits of 'offset' and 'bits'
(('ubfe', 'value', 'offset', ('iand', 31, 'bits')), ('ubfe', 'value', 'offset', 'bits')),
(('ubfe', 'value', ('iand', 31, 'offset'), 'bits'), ('ubfe', 'value', 'offset', 'bits')),
(('ibfe', 'value', 'offset', ('iand', 31, 'bits')), ('ibfe', 'value', 'offset', 'bits')),
(('ibfe', 'value', ('iand', 31, 'offset'), 'bits'), ('ibfe', 'value', 'offset', 'bits')),
(('bfm', 'bits', ('iand', 31, 'offset')), ('bfm', 'bits', 'offset')),
(('bfm', ('iand', 31, 'bits'), 'offset'), ('bfm', 'bits', 'offset')),
(('ibitfield_extract', 'value', 'offset', 'bits'), (('ibitfield_extract', 'value', 'offset', 'bits'),
('bcsel', ('ieq', 0, 'bits'), ('bcsel', ('ieq', 0, 'bits'),
0, 0,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment