NIR: fsat algebraic optimizations
This series adds a bunch of algebraic optimizations for fsat
. My observation was that, on platforms where fsat
is a modifier on an instruction, there are a number of cases where we end up with mov.sat
instructions that are unnecessary. These include cases where the instruction providing the value cannot have a saturate modifier (e.g., texture instructions) or the instruction providing the value is in a different block.
The shader-db results across the whole series except the last 3 patches is shown below. These patches relax the restrictions on the optimization added in the last non-WIP patch. A bunch of shaders are helped, but a bunch of other shaders are hurt by a pretty significant margin. I don't know that we want to include those changes, but I thought it was worth having a discussion.
Skylake
total instructions in shared programs: 15277376 -> 15271174 (-0.04%)
instructions in affected programs: 1535518 -> 1529316 (-0.40%)
helped: 3203
HURT: 0
helped stats (abs) min: 1 max: 13 x̄: 1.94 x̃: 1
helped stats (rel) min: 0.02% max: 18.75% x̄: 1.11% x̃: 0.75%
95% mean confidence interval for instructions value: -1.99 -1.88
95% mean confidence interval for instructions %-change: -1.16% -1.07%
Instructions are helped.
total cycles in shared programs: 372576967 -> 372453761 (-0.03%)
cycles in affected programs: 123472948 -> 123349742 (-0.10%)
helped: 2824
HURT: 515
helped stats (abs) min: 1 max: 2384 x̄: 58.10 x̃: 20
helped stats (rel) min: <.01% max: 26.61% x̄: 2.56% x̃: 1.65%
HURT stats (abs) min: 1 max: 5631 x̄: 79.37 x̃: 16
HURT stats (rel) min: <.01% max: 14.97% x̄: 1.37% x̃: 0.28%
95% mean confidence interval for cycles value: -42.90 -30.90
95% mean confidence interval for cycles %-change: -2.07% -1.85%
Cycles are helped.
total spills in shared programs: 23463 -> 23459 (-0.02%)
spills in affected programs: 55 -> 51 (-7.27%)
helped: 2
HURT: 0
total fills in shared programs: 31763 -> 31761 (<.01%)
fills in affected programs: 63 -> 61 (-3.17%)
helped: 2
HURT: 0
In addition to the patches included here, there are a number of patches that did not make the cut. For those interested, those changes are available in a branch.