pan/bi: Copyprop constants
Needed for constant folding to be effective. But don't copyprop into instructions already reading from FAU, that will just end up adding more moves! Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9239>
This commit is contained in:
parent
1049bb4374
commit
ff36e40145
|
@ -30,7 +30,8 @@ static bool
|
||||||
bi_is_copy(bi_instr *ins)
|
bi_is_copy(bi_instr *ins)
|
||||||
{
|
{
|
||||||
return (ins->op == BI_OPCODE_MOV_I32) && bi_is_ssa(ins->dest[0])
|
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);
|
&& (bi_is_ssa(ins->src[0]) || ins->src[0].type == BI_INDEX_FAU
|
||||||
|
|| ins->src[0].type == BI_INDEX_CONSTANT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned
|
static inline unsigned
|
||||||
|
@ -40,6 +41,17 @@ bi_word_node(bi_index idx)
|
||||||
return (idx.value << 2) | idx.offset;
|
return (idx.value << 2) | idx.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
bi_reads_fau(bi_instr *ins)
|
||||||
|
{
|
||||||
|
bi_foreach_src(ins, s) {
|
||||||
|
if (ins->src[s].type == BI_INDEX_FAU)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
bi_opt_copy_prop(bi_context *ctx)
|
bi_opt_copy_prop(bi_context *ctx)
|
||||||
{
|
{
|
||||||
|
@ -65,10 +77,13 @@ bi_opt_copy_prop(bi_context *ctx)
|
||||||
bi_index use = ins->src[s];
|
bi_index use = ins->src[s];
|
||||||
|
|
||||||
if (use.type != BI_INDEX_NORMAL || use.reg) continue;
|
if (use.type != BI_INDEX_NORMAL || use.reg) continue;
|
||||||
if (bi_count_read_registers(ins, s) != 1) continue;
|
if (s == 0 && bi_opcode_props[ins->op].sr_read) continue;
|
||||||
|
|
||||||
bi_index repl = replacement[bi_word_node(use)];
|
bi_index repl = replacement[bi_word_node(use)];
|
||||||
|
|
||||||
|
if (repl.type == BI_INDEX_CONSTANT && bi_reads_fau(ins))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!bi_is_null(repl))
|
if (!bi_is_null(repl))
|
||||||
ins->src[s] = bi_replace_index(ins->src[s], repl);
|
ins->src[s] = bi_replace_index(ins->src[s], repl);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue