From 3e4ac922987697b20a6d6fb5ff6db253ec2bb400 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Sat, 8 Feb 2025 17:02:01 +0100 Subject: [PATCH] nir/opt_algebraic: optimize ineg(a) == ineg(b) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DXBC boolean cleanup. Foz-DB Navi21: Totals from 19 (0.02% of 79188) affected shaders: Instrs: 9720 -> 9652 (-0.70%) CodeSize: 54056 -> 53640 (-0.77%) Latency: 95357 -> 94377 (-1.03%); split: -1.03%, +0.00% InvThroughput: 17331 -> 16939 (-2.26%) Copies: 604 -> 605 (+0.17%) PreSGPRs: 832 -> 838 (+0.72%) PreVGPRs: 701 -> 699 (-0.29%) VALU: 6551 -> 6485 (-1.01%) SALU: 893 -> 891 (-0.22%); split: -1.68%, +1.46% v2 (idr): Remove a pattern that is now redundant. The version without ineg already exists much earlier in the file. Search for b2iN. Reviewed-by: Ian Romanick Reviewed-by: Alyssa Rosenzweig Reviewed-by: Timur Kristóf Part-of: --- src/compiler/nir/nir_opt_algebraic.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 5fe5e2ec96e..a2d50e16ae9 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -695,6 +695,10 @@ optimizations.extend([ (('ine', ('ineg', a), 0), ('ine', a, 0)), (('ieq', ('iabs', a), 0), ('ieq', a, 0)), (('ine', ('iabs', a), 0), ('ine', a, 0)), + + (('ieq', ('ineg', a), ('ineg', b)), ('ieq', a, b)), + (('ine', ('ineg', a), ('ineg', b)), ('ine', a, b)), + (('fneu', ('fabs', a), 0.0), ('fneu', a, 0.0)), (('feq', ('fabs', a), 0.0), ('feq', a, 0.0)), (('fneu', ('fabs', a), ('fabs', a)), ('fneu', a, a)), @@ -1283,7 +1287,6 @@ optimizations.extend([ (('uge', a, 1), ('ine', a, 0)), (('ult', a, 1), ('ieq', a, 0)), - (('ine', ('ineg', ('b2i', 'a@1')), ('ineg', ('b2i', 'b@1'))), ('ine', a, b)), (('b2i', ('ine', 'a@1', 'b@1')), ('b2i', ('ixor', a, b))), (('ishl', ('b2i32', ('ine', ('iand', 'a@32', '#b(is_pos_power_of_two)'), 0)), '#c'),