From 6cfe6eaa79d16db92e3b1a75812a0dd392c183b0 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Wed, 5 Mar 2025 17:59:21 +0100 Subject: [PATCH] nir/opt_algebraic: create ldexp from exp2 ldexp uses the full width VALU path, exp2 the transcendental SIMD8. Foz-DB Navi21: Totals from 729 (0.64% of 114627) affected shaders: MaxWaves: 20071 -> 20103 (+0.16%); split: +0.18%, -0.02% Instrs: 869129 -> 867654 (-0.17%); split: -0.17%, +0.00% CodeSize: 4709000 -> 4708460 (-0.01%); split: -0.02%, +0.00% VGPRs: 31184 -> 31128 (-0.18%); split: -0.23%, +0.05% Latency: 7610726 -> 7597238 (-0.18%); split: -0.18%, +0.00% InvThroughput: 1822323 -> 1819815 (-0.14%); split: -0.14%, +0.00% VClause: 22494 -> 22493 (-0.00%); split: -0.03%, +0.02% SClause: 20520 -> 20509 (-0.05%) Copies: 72025 -> 72024 (-0.00%); split: -0.01%, +0.01% Branches: 22028 -> 22029 (+0.00%) PreVGPRs: 21601 -> 21602 (+0.00%) VALU: 604821 -> 603339 (-0.25%); split: -0.25%, +0.00% SALU: 114258 -> 114262 (+0.00%); split: -0.00%, +0.01% Reviewed-by: Alyssa Rosenzweig Part-of: --- src/compiler/nir/nir_opt_algebraic.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 922a92c062c..c56e57dabc2 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -3167,6 +3167,10 @@ optimizations += [ (('ldexp@16', 'x', 'exp'), ldexp('x', 'exp', 16), '!options->has_ldexp', TestStatus.UNSUPPORTED), # All test inputs skipped. (('ldexp@32', 'x', 'exp'), ldexp('x', 'exp', 32), '!options->has_ldexp', TestStatus.UNSUPPORTED), # All test inputs skipped. (('ldexp@64', 'x', 'exp'), ldexp('x', 'exp', 64), '!options->has_ldexp', TestStatus.UNSUPPORTED), # All test inputs skipped. + (('fexp2(contract)', ('i2f', 'a@8')), ('ldexp', 1.0, ('i2i32', a)), 'options->has_ldexp'), + (('fexp2(contract)', ('i2f', 'a@16')), ('ldexp', 1.0, ('i2i32', a)), 'options->has_ldexp'), + (('fexp2(contract)', ('i2f', 'a@32')), ('ldexp', 1.0, a), 'options->has_ldexp'), + (('fexp2(contract,ninf)', ('u2f', a)), ('ldexp', 1.0, ('u2u32', a)), 'options->has_ldexp'), ] # XCOM 2 (OpenGL) open-codes bitfieldReverse() @@ -3825,6 +3829,9 @@ late_optimizations.extend([ (('~fadd', ('fneg', ('ffmaz(is_used_once)', a, b, ('ffmaz', c, d, ('fmulz(is_used_once)', 'e(is_not_const_and_not_fsign)', 'f(is_not_const_and_not_fsign)')))), 'g(is_not_const)'), ('ffmaz', ('fneg', a), b, ('ffmaz', ('fneg', c), d, ('ffmaz', ('fneg', e), 'f', 'g'))), '(info->stage != MESA_SHADER_VERTEX && info->stage != MESA_SHADER_GEOMETRY) && !options->intel_vec4'), + (('fmul(contract)', a, ('ldexp(is_used_once)', 1.0, b)), ('ldexp', a, b), 'options->has_ldexp'), + (('frcp(contract,ninf)', ('ldexp', 1.0, b)), ('ldexp', 1.0, ('ineg', b)), 'options->has_ldexp'), + # Section 8.8 (Integer Functions) of the GLSL 4.60 spec says: # # If bits is zero, the result will be zero.