pan/mdg: Treat packs "specially"
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 13 May 2020 22:41:52 +0000 (18:41 -0400)
committerMarge Bot <eric+marge@anholt.net>
Mon, 1 Jun 2020 15:46:23 +0000 (15:46 +0000)
We maybe would prefer synthetic ops? We'll find out in due time..

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5265>

src/panfrost/midgard/compiler.h
src/panfrost/midgard/midgard_compile.c
src/panfrost/midgard/midgard_opt_copy_prop.c
src/panfrost/midgard/midgard_ra.c

index c26f82613f8aa3c41e0bf27d7fa50612ea0d4f33..3cb65b0a015c0f6c4dc04d0965c7c0e1908fc1fe 100644 (file)
@@ -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 {
index 59341feba9bfeaf8d1ea6989997425786a6f5785..196c600078a9cc23cc67cc25fed237428b813cbc 100644 (file)
@@ -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 */
index d747040edfd16c87e3f1d72699498b4072242e41..c27536f989ef3db261daa96dd869cb4ad314679e 100644 (file)
@@ -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;
index 8c6210e0634283a88b59685af4029dcc83fd4a85..112485b8b837a70a217ecdc68df0210dbf05b7f5 100644 (file)
@@ -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);