v3d: Do uniform rematerialization spilling before dropping threadcount
authorEric Anholt <eric@anholt.net>
Tue, 26 Feb 2019 18:49:25 +0000 (10:49 -0800)
committerEric Anholt <eric@anholt.net>
Tue, 5 Mar 2019 20:57:39 +0000 (12:57 -0800)
This feels like the right tradeoff for threads vs uniforms, particularly
given that we often have very short thread segments right now:

total instructions in shared programs: 6411504 -> 6413571 (0.03%)
total threads in shared programs: 153946 -> 154214 (0.17%)
total uniforms in shared programs: 2387665 -> 2393604 (0.25%)

src/broadcom/compiler/vir_register_allocate.c

index ae71e502494deee447e5ebb9050ab64c8de5f574..78f59f847446f75b0b1c560b095f3563f69d2de1 100644 (file)
@@ -586,16 +586,18 @@ v3d_register_allocate(struct v3d_compile *c, bool *spilled)
 
         bool ok = ra_allocate(g);
         if (!ok) {
-                /* Try to spill, if we can't reduce threading first. */
-                if (thread_index == 0) {
-                        int node = v3d_choose_spill_node(c, g, temp_to_node);
+                int node = v3d_choose_spill_node(c, g, temp_to_node);
 
-                        if (node != -1) {
-                                v3d_spill_reg(c, map[node].temp);
+                /* Don't emit spills using the TMU until we've dropped thread
+                 * conut first.
+                 */
+                if (node != -1 &&
+                    (vir_is_mov_uniform(c, map[node].temp) ||
+                     thread_index == 0)) {
+                        v3d_spill_reg(c, map[node].temp);
 
-                                /* Ask the outer loop to call back in. */
-                                *spilled = true;
-                        }
+                        /* Ask the outer loop to call back in. */
+                        *spilled = true;
                 }
 
                 ralloc_free(g);