pan/mdg: eliminate references to ins->alu.reg_mode
[mesa.git] / src / panfrost / midgard / midgard_opt_dce.c
index e9e51a6451dffee59b7cf29ca69aed9ba7557787..7dec286b5f92284ab933242b06ce8bff7482367f 100644 (file)
@@ -36,6 +36,9 @@ can_cull_mask(compiler_context *ctx, midgard_instruction *ins)
         if (ins->dest >= ctx->temp_count)
                 return false;
 
+        if (ins->dest == ctx->blend_src1)
+                return false;
+
         if (ins->type == TAG_LOAD_STORE_4)
                 if (load_store_opcode_props[ins->load_store.op].props & LDST_SPECIAL_MASK)
                         return false;
@@ -72,11 +75,16 @@ midgard_opt_dead_code_eliminate_block(compiler_context *ctx, midgard_block *bloc
 
         mir_foreach_instr_in_block_rev(block, ins) {
                 if (can_cull_mask(ctx, ins)) {
-                        midgard_reg_mode mode = mir_typesize(ins);
+                        unsigned type_size = nir_alu_type_get_type_size(ins->dest_type);
+                        unsigned round_size = type_size;
                         unsigned oldmask = ins->mask;
 
-                        unsigned rounded = mir_round_bytemask_up(live[ins->dest], mode);
-                        unsigned cmask = mir_from_bytemask(rounded, mode);
+                        /* Make sure we're packable */
+                        if (type_size == 16 && ins->type == TAG_LOAD_STORE_4)
+                                round_size = 32;
+
+                        unsigned rounded = mir_round_bytemask_up(live[ins->dest], round_size);
+                        unsigned cmask = mir_from_bytemask(rounded, type_size);
 
                         ins->mask &= cmask;
                         progress |= (ins->mask != oldmask);
@@ -130,7 +138,7 @@ midgard_opt_dead_move_eliminate(compiler_context *ctx, midgard_block *block)
         mir_foreach_instr_in_block_safe(block, ins) {
                 if (ins->type != TAG_ALU_4) continue;
                 if (ins->compact_branch) continue;
-                if (!OP_IS_MOVE(ins->alu.op)) continue;
+                if (!OP_IS_MOVE(ins->op)) continue;
 
                 /* Check if it's overwritten in this block before being read */
                 bool overwritten = false;