Skip to content

Improve handling of logical not in expressions and conditions

Ian Romanick requested to merge idr/mesa:inverted-conditions into master

Several of the patches in this series only affect Gen8+ platforms. Haswell results are included in this summary because it is the last pre-Gen8 platform. shader-db results across the whole series on Skylake and Haswell:

Skylake
total instructions in shared programs: 15076140 -> 15067656 (-0.06%)
instructions in affected programs: 1062982 -> 1054498 (-0.80%)
helped: 1603
HURT: 0
helped stats (abs) min: 1 max: 711 x̄: 5.29 x̃: 1
helped stats (rel) min: 0.04% max: 24.72% x̄: 0.55% x̃: 0.35%
95% mean confidence interval for instructions value: -6.94 -3.65
95% mean confidence interval for instructions %-change: -0.61% -0.50%
Instructions are helped.

total cycles in shared programs: 370135121 -> 369736507 (-0.11%)
cycles in affected programs: 116371348 -> 115972734 (-0.34%)
helped: 861
HURT: 447
helped stats (abs) min: 1 max: 28879 x̄: 600.65 x̃: 14
helped stats (rel) min: <.01% max: 22.60% x̄: 1.04% x̃: 0.40%
HURT stats (abs)   min: 1 max: 3386 x̄: 265.21 x̃: 16
HURT stats (rel)   min: 0.01% max: 21.60% x̄: 1.09% x̃: 0.35%
95% mean confidence interval for cycles value: -398.88 -210.62
95% mean confidence interval for cycles %-change: -0.43% -0.19%
Cycles are helped.

total spills in shared programs: 10158 -> 9450 (-6.97%)
spills in affected programs: 1829 -> 1121 (-38.71%)
helped: 143
HURT: 0

total fills in shared programs: 22107 -> 21117 (-4.48%)
fills in affected programs: 2575 -> 1585 (-38.45%)
helped: 143
HURT: 0

Haswell
total instructions in shared programs: 13677508 -> 13657892 (-0.14%)
instructions in affected programs: 2006696 -> 1987080 (-0.98%)
helped: 5021
HURT: 14
helped stats (abs) min: 1 max: 593 x̄: 3.94 x̃: 2
helped stats (rel) min: 0.14% max: 22.95% x̄: 1.54% x̃: 1.12%
HURT stats (abs)   min: 10 max: 24 x̄: 12.57 x̃: 10
HURT stats (rel)   min: 0.31% max: 12.24% x̄: 1.24% x̃: 0.34%
95% mean confidence interval for instructions value: -4.39 -3.41
95% mean confidence interval for instructions %-change: -1.57% -1.49%
Instructions are helped.

total cycles in shared programs: 373627882 -> 372971000 (-0.18%)
cycles in affected programs: 155337628 -> 154680746 (-0.42%)
helped: 4027
HURT: 815
helped stats (abs) min: 1 max: 38153 x̄: 193.45 x̃: 8
helped stats (rel) min: <.01% max: 21.18% x̄: 1.61% x̃: 0.69%
HURT stats (abs)   min: 1 max: 3780 x̄: 149.89 x̃: 21
HURT stats (rel)   min: <.01% max: 23.93% x̄: 2.92% x̃: 1.58%
95% mean confidence interval for cycles value: -173.79 -97.54
95% mean confidence interval for cycles %-change: -0.93% -0.76%
Cycles are helped.

total spills in shared programs: 82580 -> 81550 (-1.25%)
spills in affected programs: 71420 -> 70390 (-1.44%)
helped: 341
HURT: 14

total fills in shared programs: 93449 -> 92413 (-1.11%)
fills in affected programs: 72341 -> 71305 (-1.43%)
helped: 341
HURT: 12

This series was conceived primarily to mitigate damage that would possibly be cause by removing certain algebraic optimizations for floating-point comparisons (e.g., https://patchwork.freedesktop.org/patch/264787/). I made a change similar to this change, but my change unconditionally removed the !(a < b) and !(a >= b) transformations. That change, on its own, affected Skylake and Haswell as shown below.

Skylake
total instructions in shared programs: 15076140 -> 15105320 (0.19%)
instructions in affected programs: 1673128 -> 1702308 (1.74%)
helped: 4
HURT: 6432
helped stats (abs) min: 1 max: 41 x̄: 11.00 x̃: 1
helped stats (rel) min: 0.41% max: 1.01% x̄: 0.60% x̃: 0.48%
HURT stats (abs)   min: 1 max: 248 x̄: 4.54 x̃: 3
HURT stats (rel)   min: 0.05% max: 11.18% x̄: 2.11% x̃: 1.74%
95% mean confidence interval for instructions value: 4.32 4.74
95% mean confidence interval for instructions %-change: 2.07% 2.15%
Instructions are HURT.

total cycles in shared programs: 370135121 -> 370532679 (0.11%)
cycles in affected programs: 23870531 -> 24268089 (1.67%)
helped: 1086
HURT: 5827
helped stats (abs) min: 1 max: 5124 x̄: 71.62 x̃: 20
helped stats (rel) min: <.01% max: 37.19% x̄: 2.82% x̃: 1.07%
HURT stats (abs)   min: 1 max: 11500 x̄: 81.57 x̃: 36
HURT stats (rel)   min: <.01% max: 68.64% x̄: 4.02% x̃: 3.26%
95% mean confidence interval for cycles value: 50.43 64.59
95% mean confidence interval for cycles %-change: 2.82% 3.07%
Cycles are HURT.

total spills in shared programs: 10158 -> 10150 (-0.08%)
spills in affected programs: 166 -> 158 (-4.82%)
helped: 2
HURT: 0

total fills in shared programs: 22107 -> 22084 (-0.10%)
fills in affected programs: 440 -> 417 (-5.23%)
helped: 2
HURT: 0

LOST:   0
GAINED: 1

Haswell
total instructions in shared programs: 13677508 -> 13705746 (0.21%)
instructions in affected programs: 1577708 -> 1605946 (1.79%)
helped: 30
HURT: 6158
helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1
helped stats (rel) min: 0.47% max: 0.93% x̄: 0.64% x̃: 0.60%
HURT stats (abs)   min: 1 max: 202 x̄: 4.59 x̃: 3
HURT stats (rel)   min: 0.05% max: 11.73% x̄: 2.19% x̃: 1.83%
95% mean confidence interval for instructions value: 4.36 4.77
95% mean confidence interval for instructions %-change: 2.13% 2.22%
Instructions are HURT.

total cycles in shared programs: 373627882 -> 373944969 (0.08%)
cycles in affected programs: 23668504 -> 23985591 (1.34%)
helped: 984
HURT: 5653
helped stats (abs) min: 1 max: 3017 x̄: 71.10 x̃: 20
helped stats (rel) min: <.01% max: 62.01% x̄: 2.90% x̃: 0.83%
HURT stats (abs)   min: 1 max: 8151 x̄: 68.47 x̃: 36
HURT stats (rel)   min: <.01% max: 72.34% x̄: 3.67% x̃: 2.86%
95% mean confidence interval for cycles value: 41.75 53.80
95% mean confidence interval for cycles %-change: 2.58% 2.81%
Cycles are HURT.

That change applied on top of this series affects Skylake and Haswell as shown below. The damage is dramatically reduced.

total instructions in shared programs: 15067656 -> 15070402 (0.02%)
instructions in affected programs: 588941 -> 591687 (0.47%)
helped: 409
HURT: 1514
helped stats (abs) min: 1 max: 8 x̄: 2.13 x̃: 1
helped stats (rel) min: 0.08% max: 6.12% x̄: 0.62% x̃: 0.31%
HURT stats (abs)   min: 1 max: 200 x̄: 2.39 x̃: 2
HURT stats (rel)   min: 0.10% max: 8.09% x̄: 1.17% x̃: 1.21%
95% mean confidence interval for instructions value: 1.19 1.67
95% mean confidence interval for instructions %-change: 0.73% 0.84%
Instructions are HURT.

total cycles in shared programs: 369736507 -> 369769650 (<.01%)
cycles in affected programs: 6224225 -> 6257368 (0.53%)
helped: 823
HURT: 1629
helped stats (abs) min: 1 max: 5864 x̄: 78.82 x̃: 20
helped stats (rel) min: 0.02% max: 42.63% x̄: 3.26% x̃: 1.23%
HURT stats (abs)   min: 1 max: 7894 x̄: 60.17 x̃: 10
HURT stats (rel)   min: <.01% max: 68.67% x̄: 2.63% x̃: 0.81%
95% mean confidence interval for cycles value: -0.62 27.65
95% mean confidence interval for cycles %-change: 0.38% 0.92%
Inconclusive result (value mean confidence interval includes 0).

total fills in shared programs: 21117 -> 21115 (<.01%)
fills in affected programs: 94 -> 92 (-2.13%)
helped: 1
HURT: 0

LOST:   0
GAINED: 2

Haswell
total instructions in shared programs: 13657892 -> 13664503 (0.05%)
instructions in affected programs: 651223 -> 657834 (1.02%)
helped: 323
HURT: 2324
helped stats (abs) min: 1 max: 8 x̄: 2.17 x̃: 1
helped stats (rel) min: 0.04% max: 6.00% x̄: 0.66% x̃: 0.32%
HURT stats (abs)   min: 1 max: 200 x̄: 3.15 x̃: 3
HURT stats (rel)   min: 0.10% max: 8.09% x̄: 1.86% x̃: 1.62%
95% mean confidence interval for instructions value: 2.31 2.69
95% mean confidence interval for instructions %-change: 1.50% 1.61%
Instructions are HURT.

total cycles in shared programs: 372971000 -> 373053368 (0.02%)
cycles in affected programs: 6873148 -> 6955516 (1.20%)
helped: 657
HURT: 2504
helped stats (abs) min: 1 max: 3017 x̄: 74.10 x̃: 16
helped stats (rel) min: 0.02% max: 62.01% x̄: 2.78% x̃: 0.88%
HURT stats (abs)   min: 1 max: 8070 x̄: 52.34 x̃: 19
HURT stats (rel)   min: <.01% max: 72.50% x̄: 3.26% x̃: 1.75%
95% mean confidence interval for cycles value: 14.72 37.40
95% mean confidence interval for cycles %-change: 1.81% 2.20%
Cycles are HURT.
Edited by Ian Romanick

Merge request reports