From 0f62203edf3ec0ab6729bd69cf814b0e4480b0e8 Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Wed, 15 Mar 2023 17:25:36 +0100 Subject: [PATCH] ir3/cp: Support swapping mad srcs for shared regs This was missed when adding shared reg constraints, and helps with eliminating extra moves caused by uniform (but not const) mad sources. Part-of: --- src/freedreno/ir3/ir3_cp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/freedreno/ir3/ir3_cp.c b/src/freedreno/ir3/ir3_cp.c index 8f3133e18e1c9..33e9bd1139b03 100644 --- a/src/freedreno/ir3/ir3_cp.c +++ b/src/freedreno/ir3/ir3_cp.c @@ -280,7 +280,7 @@ try_swap_mad_two_srcs(struct ir3_instruction *instr, unsigned new_flags) /* If the reason we couldn't fold without swapping is something * other than const source, then swapping won't help: */ - if (!(new_flags & IR3_REG_CONST)) + if (!(new_flags & (IR3_REG_CONST | IR3_REG_SHARED))) return false; instr->cat3.swapped = true; @@ -338,6 +338,8 @@ reg_cp(struct ir3_cp_ctx *ctx, struct ir3_instruction *instr, unuse(src); reg->def->instr->use_count++; + return true; + } else if (n == 1 && try_swap_mad_two_srcs(instr, new_flags)) { return true; } } else if ((is_same_type_mov(src) || is_const_mov(src)) &&