Revert "panfrost/midgard: Extend copy propagation pass"
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sat, 27 Apr 2019 23:46:38 +0000 (23:46 +0000)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sun, 28 Apr 2019 21:34:32 +0000 (21:34 +0000)
Fixes: commit b53b4573c3f0571253672e44ce7d6310d9f987bf.
Optimization gone wrong. In the future, we should try this again (it's a
net win if implemented right), but at the moment this just regresses.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
src/gallium/drivers/panfrost/midgard/midgard_compile.c

index 742217c5a97e932830a96f33ff470faaf1abf1a6..0a9978655a7e4765277017cc12f7000a18efcf10 100644 (file)
@@ -3140,36 +3140,6 @@ midgard_opt_dead_code_eliminate(compiler_context *ctx, midgard_block *block)
         return progress;
 }
 
-/* Combines the two outmods if possible. Returns whether the combination was
- * successful */
-
-static bool
-midgard_combine_outmod(midgard_outmod *main, midgard_outmod overlay)
-{
-        if (overlay == midgard_outmod_none)
-                return true;
-
-        if (*main == overlay)
-                return true;
-
-        if (*main == midgard_outmod_none) {
-                *main = overlay;
-                return true;
-        }
-
-        if (*main == midgard_outmod_pos && overlay == midgard_outmod_sat) {
-                *main = midgard_outmod_sat;
-                return true;
-        }
-
-        if (overlay == midgard_outmod_pos && *main == midgard_outmod_sat) {
-                *main = midgard_outmod_sat;
-                return true;
-        }
-
-        return false;
-}
-
 static bool
 midgard_opt_copy_prop(compiler_context *ctx, midgard_block *block)
 {
@@ -3186,12 +3156,8 @@ midgard_opt_copy_prop(compiler_context *ctx, midgard_block *block)
 
                 if (to >= SSA_FIXED_MINIMUM) continue;
                 if (from >= SSA_FIXED_MINIMUM) continue;
-                if (to >= ctx->func->impl->ssa_alloc) continue;
-                if (from >= ctx->func->impl->ssa_alloc) continue;
 
-                /* Also, if the move has source side effects, we're not sure
-                 * what to do. Destination side effects we can handle, though.
-                 */
+                /* Also, if the move has side effects, we're helpless */
 
                 midgard_vector_alu_src src =
                         vector_alu_from_unsigned(ins->alu.src2);
@@ -3200,23 +3166,17 @@ midgard_opt_copy_prop(compiler_context *ctx, midgard_block *block)
 
                 if (mir_nontrivial_mod(src, is_int, mask)) continue;
 
-                mir_foreach_instr_in_block_from_rev(block, v, mir_prev_op(ins)) {
-                        if (v->ssa_args.dest == from) {
-                                if (v->type == TAG_ALU_4) {
-                                        midgard_outmod final = v->alu.outmod;
-
-                                        if (!midgard_combine_outmod(&final, ins->alu.outmod))
-                                                continue;
-
-                                        v->alu.outmod = final;
-                                }
+                mir_foreach_instr_in_block_from(block, v, mir_next_op(ins)) {
+                        if (v->ssa_args.src0 == to) {
+                                v->ssa_args.src0 = from;
+                                progress = true;
+                        }
 
-                                v->ssa_args.dest = to;
+                        if (v->ssa_args.src1 == to && !v->ssa_args.inline_constant) {
+                                v->ssa_args.src1 = from;
                                 progress = true;
                         }
                 }
-
-                mir_remove_instruction(ins);
         }
 
         return progress;