pan/midgard: Handle partial writes in liveness analysis
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 6 Aug 2019 01:17:27 +0000 (18:17 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 12 Aug 2019 19:43:01 +0000 (12:43 -0700)
This allows liveness analysis within a loop to be more fine grained,
fixing RA failures with partial spilled movs within a loop, as well as
enabling a slight reduction of register pressure more generally:

total registers in shared programs: 350 -> 347 (-0.86%)
registers in affected programs: 12 -> 9 (-25.00%)
helped: 3
HURT: 0
helped stats (abs) min: 1 max: 1 x̄: 1.00 x̃: 1
helped stats (rel) min: 25.00% max: 25.00% x̄: 25.00% x̃: 25.00%

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/panfrost/midgard/midgard_liveness.c

index 5fbab196d330dd9a99b6bf5df0641352fc6ef9c2..8ecb22ee273998c9b9a897d7034aa336ce038804 100644 (file)
@@ -46,23 +46,19 @@ is_live_after_successors(compiler_context *ctx, midgard_block *bl, int src)
                 succ->visited = true;
 
                 /* Within this block, check if it's overwritten first */
-                bool block_done = false;
+                unsigned overwritten_mask = 0;
 
                 mir_foreach_instr_in_block(succ, ins) {
-                        if (mir_has_arg(ins, src))
+                        /* Did we read any components that we haven't overwritten yet? */
+                        if (mir_mask_of_read_components(ins, src) & ~overwritten_mask)
                                 return true;
 
                         /* If written-before-use, we're gone */
 
-                        if (ins->ssa_args.dest == src && ins->mask == 0xF) {
-                                block_done = true;
-                                break;
-                        }
+                        if (ins->ssa_args.dest == src)
+                                overwritten_mask |= ins->mask;
                 }
 
-                if (block_done)
-                        continue;
-
                 /* ...and also, check *its* successors */
                 if (is_live_after_successors(ctx, succ, src))
                         return true;