aboutsummaryrefslogtreecommitdiffstats
path: root/src/panfrost
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <[email protected]>2019-07-26 13:14:55 -0700
committerAlyssa Rosenzweig <[email protected]>2019-08-02 09:57:15 -0700
commit620c2717cfd263ba6abedad1344a2e57992cbe1a (patch)
tree310646e2cc1ca6e2915704fed2f9166f601664e6 /src/panfrost
parentb821e1b85e9a2325e3ee3048ca25476ac3b32ff6 (diff)
pan/midgard: Add .not propagation pass
Essentially .pos propagation but for bitwise. Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/panfrost')
-rw-r--r--src/panfrost/midgard/compiler.h1
-rw-r--r--src/panfrost/midgard/midgard_compile.c1
-rw-r--r--src/panfrost/midgard/midgard_opt_invert.c33
3 files changed, 35 insertions, 0 deletions
diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h
index b5231f3075b..cf9db9145a3 100644
--- a/src/panfrost/midgard/compiler.h
+++ b/src/panfrost/midgard/compiler.h
@@ -576,6 +576,7 @@ bool midgard_opt_dead_move_eliminate(compiler_context *ctx, midgard_block *block
void midgard_opt_post_move_eliminate(compiler_context *ctx, midgard_block *block, struct ra_graph *g);
void midgard_lower_invert(compiler_context *ctx, midgard_block *block);
+bool midgard_opt_not_propagate(compiler_context *ctx, midgard_block *block);
bool midgard_opt_fuse_dest_invert(compiler_context *ctx, midgard_block *block);
#endif
diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c
index f0b3dde2754..a3c66ca43bb 100644
--- a/src/panfrost/midgard/midgard_compile.c
+++ b/src/panfrost/midgard/midgard_compile.c
@@ -2357,6 +2357,7 @@ midgard_compile_shader_nir(struct midgard_screen *screen, nir_shader *nir, midga
progress |= midgard_opt_dead_code_eliminate(ctx, block);
progress |= midgard_opt_combine_projection(ctx, block);
progress |= midgard_opt_varying_projection(ctx, block);
+ progress |= midgard_opt_not_propagate(ctx, block);
progress |= midgard_opt_fuse_dest_invert(ctx, block);
}
} while (progress);
diff --git a/src/panfrost/midgard/midgard_opt_invert.c b/src/panfrost/midgard/midgard_opt_invert.c
index aab64a3c3b5..ffe43a1b176 100644
--- a/src/panfrost/midgard/midgard_opt_invert.c
+++ b/src/panfrost/midgard/midgard_opt_invert.c
@@ -63,6 +63,39 @@ midgard_lower_invert(compiler_context *ctx, midgard_block *block)
}
}
+/* Propagate the .not up to the source */
+
+bool
+midgard_opt_not_propagate(compiler_context *ctx, midgard_block *block)
+{
+ bool progress = false;
+
+ mir_foreach_instr_in_block_safe(block, ins) {
+ if (ins->type != TAG_ALU_4) continue;
+ if (ins->alu.op != midgard_alu_op_imov) continue;
+ if (!ins->invert) continue;
+ if (mir_nontrivial_source2_mod_simple(ins)) continue;
+ if (ins->ssa_args.src1 & IS_REG) continue;
+
+ /* Is it beneficial to propagate? */
+ if (!mir_single_use(ctx, ins->ssa_args.src1)) continue;
+
+ /* We found an imov.not, propagate the invert back */
+
+ mir_foreach_instr_in_block_from_rev(block, v, mir_prev_op(ins)) {
+ if (v->ssa_args.dest != ins->ssa_args.src1) continue;
+ if (v->type != TAG_ALU_4) break;
+
+ v->invert = !v->invert;
+ ins->invert = false;
+ progress |= true;
+ break;
+ }
+ }
+
+ return progress;
+}
+
/* With that lowering out of the way, we can focus on more interesting
* optimizations. One easy one is fusing inverts into bitwise operations:
*