From e9c780b1d08092880a1ad769fffbad571f094c46 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 13 May 2020 18:41:52 -0400 Subject: pan/mdg: Treat packs "specially" We maybe would prefer synthetic ops? We'll find out in due time.. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/midgard/compiler.h | 5 +++++ src/panfrost/midgard/midgard_compile.c | 4 ++++ src/panfrost/midgard/midgard_opt_copy_prop.c | 2 ++ src/panfrost/midgard/midgard_ra.c | 3 +++ 4 files changed, 14 insertions(+) (limited to 'src/panfrost/midgard') diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h index c26f82613f8..3cb65b0a015 100644 --- a/src/panfrost/midgard/compiler.h +++ b/src/panfrost/midgard/compiler.h @@ -101,6 +101,11 @@ typedef struct midgard_instruction { nir_alu_type src_types[MIR_SRC_COUNT]; nir_alu_type dest_type; + /* Packing ops have non-32-bit dest types even though they functionally + * work at the 32-bit level, use this as a signal to disable copyprop. + * We maybe need synthetic pack ops instead. */ + bool is_pack; + /* Modifiers, depending on type */ union { struct { diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c index 59341feba9b..196c600078a 100644 --- a/src/panfrost/midgard/midgard_compile.c +++ b/src/panfrost/midgard/midgard_compile.c @@ -1089,15 +1089,19 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr) } else if (instr->op == nir_op_pack_32_2x16) { ins.dest_type = nir_type_uint16; ins.mask = mask_of(nr_components * 2); + ins.is_pack = true; } else if (instr->op == nir_op_pack_32_4x8) { ins.dest_type = nir_type_uint8; ins.mask = mask_of(nr_components * 4); + ins.is_pack = true; } else if (instr->op == nir_op_unpack_32_2x16) { ins.dest_type = nir_type_uint32; ins.mask = mask_of(nr_components >> 1); + ins.is_pack = true; } else if (instr->op == nir_op_unpack_32_4x8) { ins.dest_type = nir_type_uint32; ins.mask = mask_of(nr_components >> 2); + ins.is_pack = true; } /* Arrange for creation of iandnot/iornot */ diff --git a/src/panfrost/midgard/midgard_opt_copy_prop.c b/src/panfrost/midgard/midgard_opt_copy_prop.c index d747040edfd..c27536f989e 100644 --- a/src/panfrost/midgard/midgard_opt_copy_prop.c +++ b/src/panfrost/midgard/midgard_opt_copy_prop.c @@ -35,6 +35,7 @@ midgard_opt_copy_prop_reg(compiler_context *ctx, midgard_block *block) mir_foreach_instr_in_block_safe(block, ins) { if (ins->type != TAG_ALU_4) continue; if (!OP_IS_MOVE(ins->alu.op)) continue; + if (ins->is_pack) continue; unsigned from = ins->src[1]; unsigned to = ins->dest; @@ -68,6 +69,7 @@ midgard_opt_copy_prop(compiler_context *ctx, midgard_block *block) mir_foreach_instr_in_block_safe(block, ins) { if (ins->type != TAG_ALU_4) continue; if (!OP_IS_MOVE(ins->alu.op)) continue; + if (ins->is_pack) continue; unsigned from = ins->src[1]; unsigned to = ins->dest; diff --git a/src/panfrost/midgard/midgard_ra.c b/src/panfrost/midgard/midgard_ra.c index 8c6210e0634..112485b8b83 100644 --- a/src/panfrost/midgard/midgard_ra.c +++ b/src/panfrost/midgard/midgard_ra.c @@ -511,6 +511,9 @@ allocate_registers(compiler_context *ctx, bool *spilled) unsigned size = nir_alu_type_get_type_size(ins->dest_type); + if (ins->is_pack) + size = 32; + /* 0 for x, 1 for xy, 2 for xyz, 3 for xyzw */ int comps1 = util_logbase2(ins->mask); -- cgit v1.2.3