[Mesa-dev] [PATCH 1/2] nir: add pass to move load_const

Ian Romanick idr at freedesktop.org
Wed Jun 6 22:56:47 UTC 2018


On 06/06/2018 03:51 PM, Ian Romanick wrote:
> On 06/06/2018 07:43 AM, Rob Clark wrote:
>> Run this pass late (after opt loop) to move load_const instructions back
>> into the basic blocks which use the result, in cases where a load_const
>> is only consumed in a single block.
> 
> If the load_const is used in more than one block, you could use it to
> the block that dominates all of the block that contain a use.  I suspect
> in many cases that will just be the first block, but it's probably worth
> trying.
> 
>> This helps reduce register usage in cases where the backend driver
>> cannot lower the load_const to a uniform.
> 
> The trade off is that now you might not be able to hide the latency of
> the load.  I tried this on i965, and the results (below) support this
> idea a bit.  If you have a structured backend IR, this seems like a
> thing better done there... like, if you can't register allocate without
> spilling, try moving the load.  But that's really just a scheduling
> heuristic.  Hmm...
> 
> total instructions in shared programs: 14398410 -> 14397918 (<.01%)
> instructions in affected programs: 134856 -> 134364 (-0.36%)
> helped: 53
> HURT: 10
> helped stats (abs) min: 1 max: 30 x̄: 9.47 x̃: 7
> helped stats (rel) min: 0.16% max: 2.74% x̄: 0.64% x̃: 0.40%
> HURT stats (abs)   min: 1 max: 1 x̄: 1.00 x̃: 1
> HURT stats (rel)   min: 0.03% max: 0.21% x̄: 0.05% x̃: 0.03%
> 95% mean confidence interval for instructions value: -9.61 -6.01
> 95% mean confidence interval for instructions %-change: -0.68% -0.38%
> Instructions are helped.
> 
> total cycles in shared programs: 532949823 -> 532851352 (-0.02%)
> cycles in affected programs: 260693023 -> 260594552 (-0.04%)
> helped: 122
> HURT: 88
> helped stats (abs) min: 1 max: 24933 x̄: 1080.30 x̃: 20
> helped stats (rel) min: <.01% max: 34.94% x̄: 2.20% x̃: 0.32%
> HURT stats (abs)   min: 1 max: 1884 x̄: 378.69 x̃: 29
> HURT stats (rel)   min: <.01% max: 10.23% x̄: 0.64% x̃: 0.09%
> 95% mean confidence interval for cycles value: -943.71 5.89
> 95% mean confidence interval for cycles %-change: -1.71% -0.32%
> Inconclusive result (value mean confidence interval includes 0).
> 
> total spills in shared programs: 8044 -> 7975 (-0.86%)
> spills in affected programs: 2391 -> 2322 (-2.89%)
> helped: 42
> HURT: 0
> 
> total fills in shared programs: 10950 -> 10884 (-0.60%)
> fills in affected programs: 2999 -> 2933 (-2.20%)
> helped: 42
> HURT: 0
> 
> LOST:   4
> GAINED: 7

This lost result is *really* misleading.  The 4 lost shaders are compute
shaders that went from SIMD8 to SIMD16.


More information about the mesa-dev mailing list