From: Ian Romanick <ian.d.roman...@intel.com>

If both comparisons are used as sources for instructions other than the
iand, this transformation is detrimental.  If the non-identical value in
both compares is constant, the fmin or fmax will be constant-folded
away, so the transformation is always a win.

It is interesting to me that on Iron Lake only 81 shaders have
instruction counts changed, but 726 shaders have cycle counts changed.

shader-db results:

Skylake
total instructions in shared programs: 14525913 -> 14521202 (-0.03%)
instructions in affected programs: 1164726 -> 1160015 (-0.40%)
helped: 1692
HURT: 5
helped stats (abs) min: 1 max: 637 x̄: 2.79 x̃: 2
helped stats (rel) min: 0.07% max: 16.36% x̄: 0.81% x̃: 0.33%
HURT stats (abs)   min: 1 max: 12 x̄: 3.20 x̃: 1
HURT stats (rel)   min: 0.38% max: 2.86% x̄: 2.36% x̃: 2.86%
abs t: -0.06, p: 95.36%
rel t: -2.67, p: 0.76%
Inconclusive result (cannot disprove both null hypothoses).

total cycles in shared programs: 533118403 -> 532994358 (-0.02%)
cycles in affected programs: 119401803 -> 119277758 (-0.10%)
helped: 1145
HURT: 467
helped stats (abs) min: 1 max: 34644 x̄: 145.92 x̃: 18
helped stats (rel) min: <.01% max: 45.33% x̄: 1.58% x̃: 0.42%
HURT stats (abs)   min: 1 max: 1590 x̄: 92.15 x̃: 15
HURT stats (rel)   min: <.01% max: 13.48% x̄: 1.26% x̃: 0.39%
abs t: 1.07, p: 28.69%
rel t: 1.63, p: 10.42%
Inconclusive result (cannot disprove both null hypothoses).

total spills in shared programs: 9597 -> 9534 (-0.66%)
spills in affected programs: 403 -> 340 (-15.63%)
helped: 1
HURT: 1

total fills in shared programs: 13904 -> 13790 (-0.82%)
fills in affected programs: 1627 -> 1513 (-7.01%)
helped: 2
HURT: 1

LOST:   0
GAINED: 2

Broadwell
total instructions in shared programs: 14817151 -> 14812775 (-0.03%)
instructions in affected programs: 1499885 -> 1495509 (-0.29%)
helped: 1672
HURT: 15
helped stats (abs) min: 1 max: 455 x̄: 2.70 x̃: 2
helped stats (rel) min: 0.05% max: 16.36% x̄: 0.81% x̃: 0.33%
HURT stats (abs)   min: 1 max: 21 x̄: 9.20 x̃: 8
HURT stats (rel)   min: 0.08% max: 2.86% x̄: 1.06% x̃: 0.53%
abs t: -2.22, p: 2.67%
rel t: -0.77, p: 44.12%
Inconclusive result (cannot disprove both null hypothoses).

total cycles in shared programs: 559356566 -> 559348539 (<.01%)
cycles in affected programs: 139893703 -> 139885676 (<.01%)
helped: 921
HURT: 697
helped stats (abs) min: 1 max: 42424 x̄: 143.45 x̃: 18
helped stats (rel) min: <.01% max: 36.23% x̄: 2.02% x̃: 0.87%
HURT stats (abs)   min: 1 max: 2370 x̄: 178.03 x̃: 38
HURT stats (rel)   min: <.01% max: 17.35% x̄: 0.71% x̃: 0.14%
abs t: -0.62, p: 53.51%
rel t: 7.49, p: <.01%
Inconclusive result (cannot disprove both null hypothoses).

total spills in shared programs: 78902 -> 78861 (-0.05%)
spills in affected programs: 2418 -> 2377 (-1.70%)
helped: 1
HURT: 11

total fills in shared programs: 83782 -> 83678 (-0.12%)
fills in affected programs: 3515 -> 3411 (-2.96%)
helped: 2
HURT: 11

LOST:   0
GAINED: 5

Haswell
total instructions in shared programs: 13101171 -> 13098314 (-0.02%)
instructions in affected programs: 1425161 -> 1422304 (-0.20%)
helped: 1399
HURT: 7
helped stats (abs) min: 1 max: 20 x̄: 2.07 x̃: 1
helped stats (rel) min: 0.05% max: 17.54% x̄: 0.61% x̃: 0.29%
HURT stats (abs)   min: 1 max: 16 x̄: 5.57 x̃: 1
HURT stats (rel)   min: 0.08% max: 3.23% x̄: 2.01% x̃: 3.23%
abs t: -4.02, p: <.01%
rel t: -2.80, p: 0.52%
Negative result.

total cycles in shared programs: 409472082 -> 409518730 (0.01%)
cycles in affected programs: 137826107 -> 137872755 (0.03%)
helped: 663
HURT: 687
helped stats (abs) min: 1 max: 3520 x̄: 105.81 x̃: 25
helped stats (rel) min: <.01% max: 17.17% x̄: 1.66% x̃: 0.86%
HURT stats (abs)   min: 1 max: 2420 x̄: 170.02 x̃: 34
HURT stats (rel)   min: <.01% max: 18.65% x̄: 0.91% x̃: 0.14%
abs t: -4.08, p: <.01%
rel t: 5.44, p: <.01%
Inconclusive result (absolute and relative data disagree).

total spills in shared programs: 79993 -> 80002 (0.01%)
spills in affected programs: 649 -> 658 (1.39%)
helped: 0
HURT: 3

total fills in shared programs: 82625 -> 82630 (<.01%)
fills in affected programs: 678 -> 683 (0.74%)
helped: 0
HURT: 3

LOST:   0
GAINED: 4

Ivy Bridge
total instructions in shared programs: 11817596 -> 11814792 (-0.02%)
instructions in affected programs: 356814 -> 354010 (-0.79%)
helped: 961
HURT: 4
helped stats (abs) min: 1 max: 43 x̄: 2.92 x̃: 2
helped stats (rel) min: 0.09% max: 29.85% x̄: 1.02% x̃: 0.46%
HURT stats (abs)   min: 1 max: 1 x̄: 1.00 x̃: 1
HURT stats (rel)   min: 3.23% max: 3.23% x̄: 3.23% x̃: 3.23%
abs t: 0.96, p: 33.75%
rel t: -1.97, p: 4.86%
Inconclusive result (cannot disprove both null hypothoses).

total cycles in shared programs: 257563970 -> 257558995 (<.01%)
cycles in affected programs: 3433163 -> 3428188 (-0.14%)
helped: 560
HURT: 395
helped stats (abs) min: 1 max: 530 x̄: 32.88 x̃: 16
helped stats (rel) min: <.01% max: 17.17% x̄: 1.57% x̃: 0.67%
HURT stats (abs)   min: 1 max: 4240 x̄: 34.02 x̃: 9
HURT stats (rel)   min: 0.03% max: 14.39% x̄: 1.02% x̃: 0.37%
abs t: -0.12, p: 90.47%
rel t: 3.61, p: 0.03%
Inconclusive result (cannot disprove both null hypothoses).

LOST:   0
GAINED: 4

Sandy Bridge
total instructions in shared programs: 10544910 -> 10542983 (-0.02%)
instructions in affected programs: 360019 -> 358092 (-0.54%)
helped: 931
HURT: 4
helped stats (abs) min: 1 max: 20 x̄: 2.07 x̃: 1
helped stats (rel) min: 0.11% max: 15.52% x̄: 0.68% x̃: 0.30%
HURT stats (abs)   min: 1 max: 1 x̄: 1.00 x̃: 1
HURT stats (rel)   min: 3.33% max: 3.33% x̄: 3.33% x̃: 3.33%
abs t: 0.81, p: 41.83%
rel t: -3.87, p: 0.01%
Inconclusive result (cannot disprove both null hypothoses).

total cycles in shared programs: 146107787 -> 146099364 (<.01%)
cycles in affected programs: 3435047 -> 3426624 (-0.25%)
helped: 572
HURT: 329
helped stats (abs) min: 1 max: 1289 x̄: 32.52 x̃: 15
helped stats (rel) min: <.01% max: 26.29% x̄: 0.97% x̃: 0.33%
HURT stats (abs)   min: 1 max: 1714 x̄: 30.93 x̃: 6
HURT stats (rel)   min: 0.02% max: 41.31% x̄: 1.13% x̃: 0.19%
abs t: 0.21, p: 83.60%
rel t: -0.84, p: 39.85%
Inconclusive result (cannot disprove both null hypothoses).

LOST:   1
GAINED: 0

Iron Lake
total instructions in shared programs: 7886925 -> 7886711 (<.01%)
instructions in affected programs: 25763 -> 25549 (-0.83%)
helped: 75
HURT: 6
helped stats (abs) min: 1 max: 13 x̄: 3.33 x̃: 1
helped stats (rel) min: 0.35% max: 17.57% x̄: 1.96% x̃: 0.53%
HURT stats (abs)   min: 1 max: 16 x̄: 6.00 x̃: 1
HURT stats (rel)   min: 2.86% max: 4.79% x̄: 3.49% x̃: 2.86%
abs t: -1.55, p: 12.62%
rel t: -0.85, p: 39.77%
Inconclusive result (cannot disprove both null hypothoses).

total cycles in shared programs: 178116888 -> 178115324 (<.01%)
cycles in affected programs: 5858790 -> 5857226 (-0.03%)
helped: 484
HURT: 242
helped stats (abs) min: 2 max: 76 x̄: 5.27 x̃: 6
helped stats (rel) min: 0.01% max: 10.70% x̄: 0.18% x̃: 0.06%
HURT stats (abs)   min: 2 max: 76 x̄: 4.07 x̃: 2
HURT stats (rel)   min: 0.01% max: 3.99% x̄: 0.19% x̃: 0.03%
abs t: 2.14, p: 3.23%
rel t: -0.13, p: 89.88%
Inconclusive result (cannot disprove both null hypothoses).

GM45
total instructions in shared programs: 4857870 -> 4857762 (<.01%)
instructions in affected programs: 13994 -> 13886 (-0.77%)
helped: 39
HURT: 5
helped stats (abs) min: 1 max: 13 x̄: 3.28 x̃: 2
helped stats (rel) min: 0.33% max: 17.11% x̄: 1.86% x̃: 0.48%
HURT stats (abs)   min: 1 max: 16 x̄: 4.00 x̃: 1
HURT stats (rel)   min: 2.86% max: 4.71% x̄: 3.23% x̃: 2.86%
abs t: -0.37, p: 71.03%
rel t: -0.70, p: 48.55%
Inconclusive result (cannot disprove both null hypothoses).

total cycles in shared programs: 122180744 -> 122179674 (<.01%)
cycles in affected programs: 3686646 -> 3685576 (-0.03%)
helped: 273
HURT: 141
helped stats (abs) min: 2 max: 76 x̄: 5.81 x̃: 6
helped stats (rel) min: 0.01% max: 10.70% x̄: 0.18% x̃: 0.06%
HURT stats (abs)   min: 2 max: 76 x̄: 3.66 x̃: 2
HURT stats (rel)   min: 0.01% max: 3.99% x̄: 0.16% x̃: 0.02%
abs t: 2.82, p: 0.51%
rel t: 0.20, p: 83.97%
Inconclusive result (cannot disprove both null hypothoses).

Signed-off-by: Ian Romanick <ian.d.roman...@intel.com>
---
 src/compiler/nir/nir_opt_algebraic.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/compiler/nir/nir_opt_algebraic.py 
b/src/compiler/nir/nir_opt_algebraic.py
index 633ae87..2a4ba92 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -209,6 +209,14 @@ optimizations = [
    (('~ior', ('flt', '#a', c), ('flt', '#b', c)), ('flt', ('fmin', a, b), c)),
    (('~ior', ('fge', a, '#b'), ('fge', a, '#c')), ('fge', a, ('fmin', b, c))),
    (('~ior', ('fge', '#a', c), ('fge', '#b', c)), ('fge', ('fmax', a, b), c)),
+   (('~iand', ('flt(is_used_once)', a, b), ('flt', a, c)), ('flt', a, ('fmin', 
b, c))),
+   (('~iand', ('flt(is_used_once)', a, c), ('flt', b, c)), ('flt', ('fmax', a, 
b), c)),
+   (('~iand', ('fge(is_used_once)', a, b), ('fge', a, c)), ('fge', a, ('fmax', 
b, c))),
+   (('~iand', ('fge(is_used_once)', a, c), ('fge', b, c)), ('fge', ('fmin', a, 
b), c)),
+   (('~iand', ('flt', a, '#b'), ('flt', a, '#c')), ('flt', a, ('fmin', b, c))),
+   (('~iand', ('flt', '#a', c), ('flt', '#b', c)), ('flt', ('fmax', a, b), c)),
+   (('~iand', ('fge', a, '#b'), ('fge', a, '#c')), ('fge', a, ('fmax', b, c))),
+   (('~iand', ('fge', '#a', c), ('fge', '#b', c)), ('fge', ('fmin', a, b), c)),
 
    # These patterns can result when (a < b || a < c) => (a < min(b, c))
    # transformations occur before constant propagation and loop-unrolling.
-- 
2.9.5

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to