nir/opt_algebraic: optimize ~a == ~b and ~a == #b

Foz-DB Navi21:
Totals from 2 (0.00% of 79789) affected shaders:
Instrs: 8343 -> 8323 (-0.24%)
CodeSize: 43884 -> 43764 (-0.27%)
Latency: 19390 -> 19363 (-0.14%)
InvThroughput: 3380 -> 3356 (-0.71%)
VALU: 5413 -> 5393 (-0.37%)

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33761>
This commit is contained in:
Georg Lehmann 2025-02-20 13:01:52 +01:00 committed by Marge Bot
parent 8759223498
commit 3837bc6d16

View file

@ -693,6 +693,8 @@ optimizations.extend([
(('ieq', ('ineg', 'a(is_not_const)'), '#b'), ('ieq', a, ('ineg', b))),
(('ine', ('ineg', 'a(is_not_const)'), '#b'), ('ine', a, ('ineg', b))),
(('ieq', ('inot', 'a(is_not_const)'), '#b'), ('ieq', a, ('inot', b))),
(('ine', ('inot', 'a(is_not_const)'), '#b'), ('ine', a, ('inot', b))),
(('ieq', ('iabs', a), 0), ('ieq', a, 0)),
(('ine', ('iabs', a), 0), ('ine', a, 0)),
@ -701,6 +703,8 @@ optimizations.extend([
(('ieq', ('ineg', a), ('ineg', b)), ('ieq', a, b)),
(('ine', ('ineg', a), ('ineg', b)), ('ine', a, b)),
(('ieq', ('inot', a), ('inot', b)), ('ieq', a, b)),
(('ine', ('inot', a), ('inot', b)), ('ine', a, b)),
(('fneu', ('fabs', a), 0.0), ('fneu', a, 0.0)),
(('feq', ('fabs', a), 0.0), ('feq', a, 0.0)),