v3d: Rematerialize MOVs of uniforms instead of spilling them.
authorEric Anholt <eric@anholt.net>
Mon, 25 Feb 2019 23:36:26 +0000 (15:36 -0800)
committerEric Anholt <eric@anholt.net>
Tue, 26 Feb 2019 05:33:47 +0000 (21:33 -0800)
commit97566efe5cac0ff11b23d8f27001fc98c7cea2af
tree4ab67ee2bcfb296955238c7202d12e80e9cede87
parente0fada983dd24d1cd1c0a1d7e4705d4f06bc2026
v3d: Rematerialize MOVs of uniforms instead of spilling them.

If we have a MOV of a uniform value available to spill, that's one of our
best choices.  We can just not spill the value, and emit a new load of the
uniform as the fill.  This saves bothering the TMU and the thrsw, and is
the same cost in uniforms (since the spill offset is a uniform anyway).

This doesn't have a huge impact on shader-db, since there aren't a whole
lot of spills and we usually copy-prop the uniforms at the VIR level such
that the only uniform MOVs are from vir_lower_uniforms:

total instructions in shared programs: 6430292 -> 6430279 (<.01%)
total uniforms in shared programs: 2386023 -> 2385787 (<.01%)
total spills in shared programs: 4961 -> 4960 (-0.02%)
total fills in shared programs: 6352 -> 6350 (-0.03%)

However, I'm interested in dropping the uniforms copy-prop in the backend,
since it would be cheaper to not load repeated uniforms if we have the
registers to spare.  This also saves many spills on
dEQP-GLES31.functional.ubo.random.all_per_block_buffers.20, which is what
motivated a bunch of my recent backend work in the first place:

before: 46 spills, 106 fills, 3062 instructions
after: 0 spills, 0 fills, 2611 instructions
src/broadcom/compiler/v3d_compiler.h
src/broadcom/compiler/vir_register_allocate.c