From 1f9b82bb2a3f4ffcf00d5820a52ea48d0c695a08 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Mon, 21 Oct 2024 19:50:32 +0200 Subject: [PATCH] nir/opt_algebraic: optimize -0.0 + a MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Foz-DB Navi21: Totals from 428 (0.54% of 79395) affected shaders: MaxWaves: 8510 -> 8512 (+0.02%) Instrs: 731062 -> 729665 (-0.19%); split: -0.19%, +0.00% CodeSize: 3735788 -> 3728324 (-0.20%); split: -0.20%, +0.00% VGPRs: 27328 -> 27336 (+0.03%); split: -0.03%, +0.06% SpillSGPRs: 315 -> 314 (-0.32%) Latency: 3872986 -> 3873236 (+0.01%); split: -0.08%, +0.09% InvThroughput: 971001 -> 970056 (-0.10%); split: -0.17%, +0.08% VClause: 11954 -> 11956 (+0.02%); split: -0.02%, +0.03% SClause: 17361 -> 17358 (-0.02%) Copies: 59038 -> 59045 (+0.01%); split: -0.22%, +0.24% Branches: 17685 -> 17656 (-0.16%) PreSGPRs: 26103 -> 26102 (-0.00%) PreVGPRs: 23220 -> 23206 (-0.06%) VALU: 515293 -> 513963 (-0.26%); split: -0.26%, +0.00% SALU: 91591 -> 91544 (-0.05%) Reviewed-by: Alyssa Rosenzweig Reviewed-by: Timur Kristóf Part-of: --- src/compiler/nir/nir_opt_algebraic.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index e014b2a5d0b..db7feed9057 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -202,6 +202,8 @@ optimizations = [ # floating point instruction, they should flush any input denormals and we # can replace -0.0 with 0.0 if the float execution mode allows it. (('fadd(is_only_used_as_float,nsz)', 'a', 0.0), a), + (('fadd(is_only_used_as_float)', a, '#b(is_negative_zero)'), a), + (('fadd', ('fneg', a), '#b(is_negative_zero)'), ('fneg', a)), (('iadd', a, 0), a), (('iadd_sat', a, 0), a), (('isub_sat', a, 0), a),