Skip to content

intel/fs: Completely rewrite the combine-constants pass

Ian Romanick requested to merge idr/mesa:review/combine-constants into main

This series completely rewrites the existing combine-constants pass in the Intel FS backend. This project started off because we're going to want something similar to that pass for IBC. I initially thought this could be accomplished in NIR, but I didn't fully understand all the things the original pass was doing.

There is a generic implementation of combine-constants added in src/util. There is a very stale use of the generic combine-constants pass in NIR. This patch is marked "FYI," and it is only included as simple example of how to use the generic code. It should be pretty easy to create a version of the adapter for IBC.

The current version of the generic combine-constants code uses a greedy algorithm. The greedy implementation does not produce as good results as the previous global optimization version. Spill and fills were reduced by quite a bit more in that version. The greedy implementation is not a waste, however. Branch-and-bound global optimizers (and many related algorithms) have much, much better run-time when the are provided with a higher quality initial solution. The greedy algorithm provides such an initial solution.

Shader-db results across the whole series for Ice Lake (updated on 16-May-2022):

total instructions in shared programs: 20127055 -> 20113398 (-0.07%)
instructions in affected programs: 1045636 -> 1031979 (-1.31%)
helped: 1447
HURT: 2
helped stats (abs) min: 1 max: 1152 x̄: 9.46 x̃: 1
helped stats (rel) min: 0.05% max: 23.87% x̄: 0.75% x̃: 0.43%
HURT stats (abs)   min: 16 max: 16 x̄: 16.00 x̃: 16
HURT stats (rel)   min: 1.45% max: 1.45% x̄: 1.45% x̃: 1.45%
95% mean confidence interval for instructions value: -12.71 -6.14
95% mean confidence interval for instructions %-change: -0.85% -0.64%
Instructions are helped.

total cycles in shared programs: 859812882 -> 856513560 (-0.38%)
cycles in affected programs: 469192873 -> 465893551 (-0.70%)
helped: 2228
HURT: 1929
helped stats (abs) min: 1 max: 405993 x̄: 1823.64 x̃: 18
helped stats (rel) min: <.01% max: 62.97% x̄: 1.78% x̃: 0.28%
HURT stats (abs)   min: 1 max: 37895 x̄: 395.93 x̃: 22
HURT stats (rel)   min: <.01% max: 72.28% x̄: 2.46% x̃: 0.35%
95% mean confidence interval for cycles value: -1163.09 -424.27
95% mean confidence interval for cycles %-change: <.01% 0.37%
Inconclusive result (value mean confidence interval and %-change mean confidence interval disagree).

total spills in shared programs: 9475 -> 8720 (-7.97%)
spills in affected programs: 2717 -> 1962 (-27.79%)
helped: 307
HURT: 2

total fills in shared programs: 11362 -> 9570 (-15.77%)
fills in affected programs: 5201 -> 3409 (-34.45%)
helped: 307
HURT: 2

LOST:   7
GAINED: 26

And fossil-db:

Instructions in all programs: 142337460 -> 142200570 (-0.1%)
Instructions helped: 30591
Instructions hurt: 176

Cycles in all programs: 8802608665 -> 8803402193 (+0.0%)
Cycles helped: 42988
Cycles hurt: 39230

Spills in all programs: 101347 -> 95917 (-5.4%)
Spills helped: 473
Spills hurt: 4

Fills in all programs: 129684 -> 121138 (-6.6%)
Fills helped: 473
Fills hurt: 4

Gained: 80
Lost: 135
Edited by Ian Romanick

Merge request reports