nir/opt_algebraic: optimize b2i(a) != -b2i(b)

Foz-DB Navi21:
Totals from 4 (0.01% of 79377) affected shaders:
Instrs: 881 -> 861 (-2.27%)
CodeSize: 4968 -> 4836 (-2.66%)
Latency: 6127 -> 6006 (-1.97%)
InvThroughput: 1128 -> 1068 (-5.32%)
VALU: 564 -> 534 (-5.32%)
SALU: 111 -> 121 (+9.01%)

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33498>
This commit is contained in:
Georg Lehmann 2025-02-12 14:39:14 +01:00 committed by Marge Bot
parent 4141043295
commit a237a3def8

View file

@ -1480,6 +1480,9 @@ optimizations.extend([
('iand', ('ishl', -1, b), ('ineg', ('b2i', a)))),
(('ushr', ('ineg', ('b2i', a)), '#b'),
('iand', ('ushr', -1, b), ('ineg', ('b2i', a)))),
(('ine', ('b2i', 'a@1'), ('ineg', ('b2i', 'b@1'))), ('ior', a, b)),
(('ieq', ('b2i', 'a@1'), ('ineg', ('b2i', 'b@1'))), ('inot', ('ior', a, b))),
])
for op in ('ior', 'iand', 'ixor'):