From 2a9031ea448f56d483bf411f2fac46437e9dee47 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 13 Aug 2019 15:58:49 -0700 Subject: [PATCH] pan/midgard: Use hint on midgard_instruction for spill_move This allows us to have multiple spill moves, whereas otherwise for N spill moves, the first N-1 would be clobbered. Issue found in Krita. Signed-off-by: Alyssa Rosenzweig --- src/panfrost/midgard/compiler.h | 3 +++ src/panfrost/midgard/midgard_schedule.c | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h index d62157f3be4..cf7547ccda3 100644 --- a/src/panfrost/midgard/compiler.h +++ b/src/panfrost/midgard/compiler.h @@ -134,6 +134,9 @@ typedef struct midgard_instruction { bool no_spill; + /* Generic hint for intra-pass use */ + bool hint; + union { midgard_load_store_word load_store; midgard_vector_alu alu; diff --git a/src/panfrost/midgard/midgard_schedule.c b/src/panfrost/midgard/midgard_schedule.c index 486bb38e049..ce97287d199 100644 --- a/src/panfrost/midgard/midgard_schedule.c +++ b/src/panfrost/midgard/midgard_schedule.c @@ -775,7 +775,6 @@ static void mir_spill_register( /* Allocate TLS slot (maybe) */ unsigned spill_slot = !is_special ? (*spill_count)++ : 0; - midgard_instruction *spill_move = NULL; /* For TLS, replace all stores to the spilled node. For * special reads, just keep as-is; the class will be demoted @@ -796,7 +795,10 @@ static void mir_spill_register( st = v_load_store_scratch(ins->ssa_args.dest, spill_slot, true, ins->mask); } - spill_move = mir_insert_instruction_before(mir_next_op(ins), st); + /* Hint: don't rewrite this node */ + st.hint = true; + + mir_insert_instruction_before(mir_next_op(ins), st); if (!is_special) ctx->spills++; @@ -824,8 +826,9 @@ static void mir_spill_register( unsigned consecutive_index = 0; mir_foreach_instr_in_block(block, ins) { - /* We can't rewrite the move used to spill in the first place */ - if (ins == spill_move) continue; + /* We can't rewrite the moves used to spill in the + * first place. These moves are hinted. */ + if (ins->hint) continue; if (!mir_has_arg(ins, spill_node)) { consecutive_skip = false; @@ -878,6 +881,12 @@ static void mir_spill_register( ctx->fills++; } } + + /* Reset hints */ + + mir_foreach_instr_global(ctx, ins) { + ins->hint = false; + } } void -- 2.30.2