From: Ian Romanick <ian.d.roman...@intel.com> This was specifically designed to simplify 1+mix(0, a-1, condition) to mix(1, a, condition) by pushing the 1+ inside.
Skylake, Broadwell, and Haswell had similar results. Skylake shown. total instructions in shared programs: 14521938 -> 14521901 (<.01%) instructions in affected programs: 10619 -> 10582 (-0.35%) helped: 51 HURT: 14 helped stats (abs) min: 1 max: 12 x̄: 1.43 x̃: 1 helped stats (rel) min: 0.20% max: 3.58% x̄: 1.01% x̃: 0.95% HURT stats (abs) min: 1 max: 11 x̄: 2.57 x̃: 1 HURT stats (rel) min: 0.22% max: 1.75% x̄: 1.20% x̃: 1.32% abs t: -1.50, p: 13.87% rel t: -1.11, p: 27.06% Inconclusive result (cannot disprove both null hypothoses). total cycles in shared programs: 533003159 -> 533006487 (<.01%) cycles in affected programs: 110610 -> 113938 (3.01%) helped: 43 HURT: 28 helped stats (abs) min: 6 max: 440 x̄: 27.12 x̃: 16 helped stats (rel) min: 0.39% max: 4.84% x̄: 1.60% x̃: 1.67% HURT stats (abs) min: 2 max: 3066 x̄: 160.50 x̃: 14 HURT stats (rel) min: 0.08% max: 77.78% x̄: 5.16% x̃: 0.62% abs t: -1.47, p: 14.70% rel t: -1.43, p: 15.77% Inconclusive result (cannot disprove both null hypothoses). Ivy Bridge, Sandy Bridge, and Iron Lake had similar results. Ivy Bridge shown. total instructions in shared programs: 11817064 -> 11816937 (<.01%) instructions in affected programs: 9431 -> 9304 (-1.35%) helped: 51 HURT: 3 helped stats (abs) min: 1 max: 80 x̄: 2.76 x̃: 1 helped stats (rel) min: 0.20% max: 16.43% x̄: 1.16% x̃: 0.81% HURT stats (abs) min: 1 max: 12 x̄: 4.67 x̃: 1 HURT stats (rel) min: 0.22% max: 1.33% x̄: 0.59% x̃: 0.22% abs t: -0.29, p: 77.20% rel t: 0.44, p: 66.15% Inconclusive result (cannot disprove both null hypothoses). total cycles in shared programs: 257573443 -> 257574281 (<.01%) cycles in affected programs: 123831 -> 124669 (0.68%) helped: 44 HURT: 24 helped stats (abs) min: 2 max: 114 x̄: 49.93 x̃: 30 helped stats (rel) min: 0.11% max: 11.01% x̄: 4.26% x̃: 2.73% HURT stats (abs) min: 1 max: 2341 x̄: 126.46 x̃: 12 HURT stats (rel) min: 0.06% max: 37.11% x̄: 2.67% x̃: 0.63% abs t: -1.07, p: 28.77% rel t: 1.19, p: 23.86% Inconclusive result (cannot disprove both null hypothoses). GM45 total instructions in shared programs: 4857762 -> 4857661 (<.01%) instructions in affected programs: 5523 -> 5422 (-1.83%) helped: 25 HURT: 1 helped stats (abs) min: 1 max: 78 x̄: 4.08 x̃: 1 helped stats (rel) min: 0.34% max: 13.61% x̄: 1.04% x̃: 0.52% HURT stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1 HURT stats (rel) min: 0.86% max: 0.86% x̄: 0.86% x̃: 0.86% total cycles in shared programs: 122179674 -> 122179194 (<.01%) cycles in affected programs: 530162 -> 529682 (-0.09%) helped: 22 HURT: 1 helped stats (abs) min: 2 max: 292 x̄: 21.91 x̃: 7 helped stats (rel) min: <.01% max: 8.65% x̄: 0.44% x̃: 0.04% HURT stats (abs) min: 2 max: 2 x̄: 2.00 x̃: 2 HURT stats (rel) min: 0.03% max: 0.03% x̄: 0.03% x̃: 0.03% Signed-off-by: Ian Romanick <ian.d.roman...@intel.com> --- src/compiler/nir/nir_opt_algebraic.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index d9ca57b..35fe8af 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -602,6 +602,21 @@ for op in ['flt', 'fge', 'feq', 'fne', ('bcsel', 'a', (op, 'd', 'b'), (op, 'd', 'c'))), ] + +# For example, this converts things like +# +# 1 + mix(0, a - 1, condition) +# +# into +# +# mix(1, (a-1)+1, condition) +# +# Other optimizations will rearrange the constants. +for op in ['fadd', 'fmul', 'iadd', 'imul']: + optimizations += [ + ((op, ('bcsel(is_used_once)', a, '#b', c), '#d'), ('bcsel', a, (op, b, d), (op, c, d))) + ] + # This section contains "late" optimizations that should be run before # creating ffmas and calling regular optimizations for the final time. # Optimizations should go here if they help code generation and conflict -- 2.9.5 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev