From a237a3def8f172127d6625b21d77f8ab5cbb6d20 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Wed, 12 Feb 2025 14:39:14 +0100 Subject: [PATCH] nir/opt_algebraic: optimize b2i(a) != -b2i(b) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Alyssa Rosenzweig Reviewed-by: Timur Kristóf Part-of: --- src/compiler/nir/nir_opt_algebraic.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 8c999042e92..6a6d6d997fd 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -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'):