diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-04-21 16:11:11 +0000 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-04-24 02:22:31 +0000 |
commit | 84f09ff43328f2cb56c041fee36735802de8a378 (patch) | |
tree | a96a61ede5e5c0c7ebf579d8f2a4cb64cf564705 | |
parent | 328a5ef598db141ffbec638fb831f9047cb687bf (diff) |
panfrost/midgard: Dead code eliminate MIR
We reshuffle the existing "dead move elimination" pass into a generic
dead code elimination layer, fixing bugs incurred with looping in the
process.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
-rw-r--r-- | src/gallium/drivers/panfrost/midgard/midgard_compile.c | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/src/gallium/drivers/panfrost/midgard/midgard_compile.c b/src/gallium/drivers/panfrost/midgard/midgard_compile.c index 317f25762dc..7fe5b98b0ab 100644 --- a/src/gallium/drivers/panfrost/midgard/midgard_compile.c +++ b/src/gallium/drivers/panfrost/midgard/midgard_compile.c @@ -643,8 +643,6 @@ print_mir_block(midgard_block *block) printf("}\n"); } - - static void attach_constants(compiler_context *ctx, midgard_instruction *ins, void *constants, int name) { @@ -3045,26 +3043,18 @@ map_ssa_to_alias(compiler_context *ctx, int *ref) } } -#define AS_SRC(to, u) \ - int q##to = ins->alu.src2; \ - midgard_vector_alu_src *to = (midgard_vector_alu_src *) &q##to; - -/* Removing unused moves is necessary to clean up the texture pipeline results. - * - * To do so, we find moves in the MIR. We check if their destination is live later. If it's not, the move is redundant. */ +/* Basic dead code elimination on the MIR itself, which cleans up e.g. the + * texture pipeline */ static void -midgard_eliminate_orphan_moves(compiler_context *ctx, midgard_block *block) +midgard_opt_dead_code_eliminate(compiler_context *ctx, midgard_block *block) { mir_foreach_instr_in_block_safe(block, ins) { if (ins->type != TAG_ALU_4) continue; - - if (ins->alu.op != midgard_alu_op_fmov) continue; + if (ins->compact_branch) continue; if (ins->ssa_args.dest >= SSA_FIXED_MINIMUM) continue; - if (midgard_is_pinned(ctx, ins->ssa_args.dest)) continue; - if (is_live_after(ctx, block, ins, ins->ssa_args.dest)) continue; mir_remove_instruction(ins); @@ -3321,7 +3311,6 @@ emit_block(compiler_context *ctx, nir_block *block) actualise_ssa_to_alias(ctx); midgard_emit_store(ctx, this_block); - midgard_eliminate_orphan_moves(ctx, this_block); midgard_pair_load_store(ctx, this_block); /* Append fragment shader epilogue (value writeout) */ @@ -3608,6 +3597,12 @@ midgard_compile_shader_nir(nir_shader *nir, midgard_program *program, bool is_bl util_dynarray_init(compiled, NULL); + /* Peephole optimizations */ + + mir_foreach_block(ctx, block) { + midgard_opt_dead_code_eliminate(ctx, block); + } + /* Schedule! */ schedule_program(ctx); |