From e94e6c49f1e6b812445e62fac064244f478903ab Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 25 Jul 2022 15:00:39 -0400 Subject: [PATCH] pan/bi: Assume SSA in copyprop Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_opt_copy_prop.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/panfrost/bifrost/bi_opt_copy_prop.c b/src/panfrost/bifrost/bi_opt_copy_prop.c index 89798e5..adbac98 100644 --- a/src/panfrost/bifrost/bi_opt_copy_prop.c +++ b/src/panfrost/bifrost/bi_opt_copy_prop.c @@ -25,15 +25,7 @@ #include "compiler.h" #include "bi_builder.h" -/* A simple scalar-only SSA-based copy-propagation pass. TODO: vectors */ - -static bool -bi_is_copy(bi_instr *ins) -{ - return (ins->op == BI_OPCODE_MOV_I32) && bi_is_ssa(ins->dest[0]) - && (bi_is_ssa(ins->src[0]) || ins->src[0].type == BI_INDEX_FAU - || ins->src[0].type == BI_INDEX_CONSTANT); -} +/* SSA copy propagation */ static bool bi_reads_fau(bi_instr *ins) @@ -60,16 +52,12 @@ bi_opt_copy_prop(bi_context *ctx) if (I->nr_srcs == 1) I->op = BI_OPCODE_MOV_I32; - if (bi_is_ssa(I->dest[0])) - collects[I->dest[0].value] = I; + collects[I->dest[0].value] = I; } else if (I->op == BI_OPCODE_SPLIT_I32) { /* Rewrite trivial splits while we're at it */ if (I->nr_dests == 1) I->op = BI_OPCODE_MOV_I32; - if (!bi_is_ssa(I->src[0])) - continue; - bi_instr *collect = collects[I->src[0].value]; if (!collect) continue; @@ -89,7 +77,7 @@ bi_opt_copy_prop(bi_context *ctx) bi_index *replacement = calloc(sizeof(bi_index), ctx->ssa_alloc); bi_foreach_instr_global_safe(ctx, ins) { - if (bi_is_copy(ins)) { + if (ins->op == BI_OPCODE_MOV_I32 && ins->src[0].type != BI_INDEX_REGISTER) { bi_index replace = ins->src[0]; /* Peek through one layer so copyprop converges in one @@ -108,7 +96,7 @@ bi_opt_copy_prop(bi_context *ctx) bi_foreach_src(ins, s) { bi_index use = ins->src[s]; - if (use.type != BI_INDEX_NORMAL || use.reg) continue; + if (use.type != BI_INDEX_NORMAL) continue; if (bi_is_staging_src(ins, s)) continue; bi_index repl = replacement[use.value]; -- 2.7.4