nir: Add nir_foreach_shader_in/out_variable helpers
[mesa.git] / src / panfrost / midgard / midgard_opt_dce.c
index be9307e712a746c1be7c05d2db4c15ecbb997076..86812b5b0fe5d628403494c4ec253d42b5f88d12 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;
@@ -73,9 +76,14 @@ 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)) {
                         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], type_size);
+                        /* 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;