mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-21 11:30:11 +01:00
nir/opt_algebraic: optimize patterns from Skia
shaders/skia/1567.shader_test relies on algebraic + constant folding, subtle changes in the input compiling flow can cause it to baloon. these patterns fix that. annoying! shader-db results aren't amazing, but they avert a major stats regression for that one Skia shader. total instructions in shared programs: 2751399 -> 2751295 (<.01%) instructions in affected programs: 6509 -> 6405 (-1.60%) helped: 21 HURT: 1 helped stats (abs) min: 1 max: 14 x̄: 5.62 x̃: 6 helped stats (rel) min: 0.53% max: 13.73% x̄: 3.57% x̃: 1.62% HURT stats (abs) min: 14 max: 14 x̄: 14.00 x̃: 14 HURT stats (rel) min: 2.45% max: 2.45% x̄: 2.45% x̃: 2.45% 95% mean confidence interval for instructions value: -7.09 -2.36 95% mean confidence interval for instructions %-change: -5.14% -1.45% Instructions are helped. total alu in shared programs: 2274577 -> 2274468 (<.01%) alu in affected programs: 6178 -> 6069 (-1.76%) helped: 21 HURT: 1 helped stats (abs) min: 1 max: 14 x̄: 5.86 x̃: 7 helped stats (rel) min: 0.55% max: 16.47% x̄: 3.93% x̃: 1.72% HURT stats (abs) min: 14 max: 14 x̄: 14.00 x̃: 14 HURT stats (rel) min: 2.83% max: 2.83% x̄: 2.83% x̃: 2.83% 95% mean confidence interval for alu value: -7.35 -2.56 95% mean confidence interval for alu %-change: -5.67% -1.57% Alu are helped. total fscib in shared programs: 2272894 -> 2272785 (<.01%) fscib in affected programs: 6178 -> 6069 (-1.76%) helped: 21 HURT: 1 helped stats (abs) min: 1 max: 14 x̄: 5.86 x̃: 7 helped stats (rel) min: 0.55% max: 16.47% x̄: 3.93% x̃: 1.72% HURT stats (abs) min: 14 max: 14 x̄: 14.00 x̃: 14 HURT stats (rel) min: 2.83% max: 2.83% x̄: 2.83% x̃: 2.83% 95% mean confidence interval for fscib value: -7.35 -2.56 95% mean confidence interval for fscib %-change: -5.67% -1.57% Fscib are helped. total bytes in shared programs: 21489352 -> 21488668 (<.01%) bytes in affected programs: 53362 -> 52678 (-1.28%) helped: 21 HURT: 2 helped stats (abs) min: 6 max: 98 x̄: 35.52 x̃: 40 helped stats (rel) min: 0.39% max: 10.63% x̄: 2.27% x̃: 1.27% HURT stats (abs) min: 2 max: 60 x̄: 31.00 x̃: 31 HURT stats (rel) min: 0.08% max: 1.40% x̄: 0.74% x̃: 0.74% 95% mean confidence interval for bytes value: -42.73 -16.74 95% mean confidence interval for bytes %-change: -3.13% -0.89% Bytes are helped. total regs in shared programs: 865162 -> 865148 (<.01%) regs in affected programs: 509 -> 495 (-2.75%) helped: 4 HURT: 5 helped stats (abs) min: 2 max: 14 x̄: 6.00 x̃: 4 helped stats (rel) min: 3.17% max: 35.90% x̄: 14.01% x̃: 8.48% HURT stats (abs) min: 2 max: 2 x̄: 2.00 x̃: 2 HURT stats (rel) min: 3.17% max: 3.17% x̄: 3.17% x̃: 3.17% 95% mean confidence interval for regs value: -5.75 2.64 95% mean confidence interval for regs %-change: -14.31% 5.39% Inconclusive result (value mean confidence interval includes 0). total uniforms in shared programs: 2120731 -> 2120735 (<.01%) uniforms in affected programs: 358 -> 362 (1.12%) helped: 1 HURT: 2 helped stats (abs) min: 2 max: 2 x̄: 2.00 x̃: 2 helped stats (rel) min: 2.94% max: 2.94% x̄: 2.94% x̃: 2.94% HURT stats (abs) min: 2 max: 4 x̄: 3.00 x̃: 3 HURT stats (rel) min: 1.05% max: 4.00% x̄: 2.53% x̃: 2.53% Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Karol Herbst <kherbst@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31964>
This commit is contained in:
parent
015f6a7aff
commit
a4a3487aae
1 changed files with 6 additions and 0 deletions
|
|
@ -946,6 +946,12 @@ optimizations.extend([
|
||||||
# fmin(0.0, b)) while the right one is "b", so this optimization is inexact.
|
# fmin(0.0, b)) while the right one is "b", so this optimization is inexact.
|
||||||
(('~fmin', ('fsat', a), '#b(is_zero_to_one)'), ('fsat', ('fmin', a, b))),
|
(('~fmin', ('fsat', a), '#b(is_zero_to_one)'), ('fsat', ('fmin', a, b))),
|
||||||
|
|
||||||
|
# If a >= 0 ... 1 + a >= 1 ... so fsat(1 + a) = 1
|
||||||
|
(('fsat', ('fadd', 1.0, 'a(is_ge_zero)')), 1.0),
|
||||||
|
|
||||||
|
# Let constant folding do its job. This can have emergent behaviour.
|
||||||
|
(('fneg', ('bcsel(is_used_once)', a, '#b', '#c')), ('bcsel', a, ('fneg', b), ('fneg', c))),
|
||||||
|
|
||||||
# max(-min(b, a), b) -> max(abs(b), -a)
|
# max(-min(b, a), b) -> max(abs(b), -a)
|
||||||
# min(-max(b, a), b) -> min(-abs(b), -a)
|
# min(-max(b, a), b) -> min(-abs(b), -a)
|
||||||
(('fmax', ('fneg', ('fmin', b, a)), b), ('fmax', ('fabs', b), ('fneg', a))),
|
(('fmax', ('fneg', ('fmin', b, a)), b), ('fmax', ('fabs', b), ('fneg', a))),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue