Mesa (main): nir/algebraic: add is_used_once to dot product reassociation optimization

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 16 18:05:35 UTC 2021


Module: Mesa
Branch: main
Commit: 4ec4d862c2a17ef7ae79ceb23cd7f0942a13d64b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4ec4d862c2a17ef7ae79ceb23cd7f0942a13d64b

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Thu May 13 12:50:09 2021 +0100

nir/algebraic: add is_used_once to dot product reassociation optimization

This improves register usage.

fossil-db (Sienna Cichlid, on top of !9805):
Totals from 4317 (2.88% of 149839) affected shaders:
VGPRs: 352592 -> 351704 (-0.25%); split: -1.48%, +1.23%
SpillSGPRs: 182 -> 248 (+36.26%)
CodeSize: 31601192 -> 31587624 (-0.04%); split: -0.09%, +0.04%
MaxWaves: 56964 -> 57298 (+0.59%); split: +2.48%, -1.90%
Instrs: 5973557 -> 5974122 (+0.01%); split: -0.05%, +0.06%
Latency: 72088175 -> 72253033 (+0.23%); split: -0.36%, +0.59%
InvThroughput: 14978160 -> 14798919 (-1.20%); split: -1.29%, +0.09%
VClause: 100994 -> 98645 (-2.33%); split: -3.05%, +0.73%
SClause: 278206 -> 276820 (-0.50%); split: -0.54%, +0.04%
Copies: 200264 -> 199556 (-0.35%); split: -1.17%, +0.82%
Branches: 86410 -> 85930 (-0.56%); split: -0.56%, +0.01%
PreSGPRs: 207355 -> 207759 (+0.19%); split: -0.00%, +0.20%
PreVGPRs: 314646 -> 310911 (-1.19%); split: -1.35%, +0.17%

Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8056>

---

 src/compiler/nir/nir_opt_algebraic.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index 4a9a72cc7f8..51f2d18c2ca 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -2388,11 +2388,11 @@ late_optimizations = [
    # optimization in these stages.  See bugzilla #111490.  In tessellation
    # stages applications seem to use 'precise' when necessary, so allow the
    # optimization in those stages.
-   (('~fadd', ('ffma(is_used_once)', a, b, ('ffma', c, d, ('fmul', 'e(is_not_const_and_not_fsign)', 'f(is_not_const_and_not_fsign)'))), 'g(is_not_const)'),
+   (('~fadd', ('ffma(is_used_once)', a, b, ('ffma', c, d, ('fmul(is_used_once)', 'e(is_not_const_and_not_fsign)', 'f(is_not_const_and_not_fsign)'))), 'g(is_not_const)'),
     ('ffma', a, b, ('ffma', c, d, ('ffma', e, 'f', 'g'))), '(info->stage != MESA_SHADER_VERTEX && info->stage != MESA_SHADER_GEOMETRY) && !options->intel_vec4'),
-   (('~fadd', ('ffma(is_used_once)', a, b, ('fmul', 'c(is_not_const_and_not_fsign)', 'd(is_not_const_and_not_fsign)') ), 'e(is_not_const)'),
+   (('~fadd', ('ffma(is_used_once)', a, b, ('fmul(is_used_once)', 'c(is_not_const_and_not_fsign)', 'd(is_not_const_and_not_fsign)') ), 'e(is_not_const)'),
     ('ffma', a, b, ('ffma', c, d, e)), '(info->stage != MESA_SHADER_VERTEX && info->stage != MESA_SHADER_GEOMETRY) && !options->intel_vec4'),
-   (('~fadd', ('fneg', ('ffma(is_used_once)', a, b, ('ffma', c, d, ('fmul', 'e(is_not_const_and_not_fsign)', 'f(is_not_const_and_not_fsign)')))), 'g(is_not_const)'),
+   (('~fadd', ('fneg', ('ffma(is_used_once)', a, b, ('ffma', c, d, ('fmul(is_used_once)', 'e(is_not_const_and_not_fsign)', 'f(is_not_const_and_not_fsign)')))), 'g(is_not_const)'),
     ('ffma', ('fneg', a), b, ('ffma', ('fneg', c), d, ('ffma', ('fneg', e), 'f', 'g'))), '(info->stage != MESA_SHADER_VERTEX && info->stage != MESA_SHADER_GEOMETRY) && !options->intel_vec4'),
 
    # Section 8.8 (Integer Functions) of the GLSL 4.60 spec says:



More information about the mesa-commit mailing list