mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-22 14:00:37 +02:00
pan/midgard: Fix invert fusing with r26
The invert wasn't applying (correctly) due to the issues addressed here. Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
This commit is contained in:
parent
75b6be2435
commit
c30116a2fa
2 changed files with 19 additions and 2 deletions
|
|
@ -193,6 +193,9 @@ midgard_opt_fuse_dest_invert(compiler_context *ctx, midgard_block *block)
|
|||
static bool
|
||||
mir_strip_inverted(compiler_context *ctx, unsigned node)
|
||||
{
|
||||
if (node >= SSA_FIXED_MINIMUM)
|
||||
return false;
|
||||
|
||||
/* Strips and returns the invert off a node */
|
||||
mir_foreach_instr_global(ctx, ins) {
|
||||
if (ins->compact_branch) continue;
|
||||
|
|
@ -206,6 +209,12 @@ mir_strip_inverted(compiler_context *ctx, unsigned node)
|
|||
unreachable("Invalid node stripped");
|
||||
}
|
||||
|
||||
static bool
|
||||
is_ssa_or_constant(unsigned node)
|
||||
{
|
||||
return !(node & IS_REG) || (node == SSA_FIXED_REGISTER(26));
|
||||
}
|
||||
|
||||
bool
|
||||
midgard_opt_fuse_src_invert(compiler_context *ctx, midgard_block *block)
|
||||
{
|
||||
|
|
@ -217,8 +226,8 @@ midgard_opt_fuse_src_invert(compiler_context *ctx, midgard_block *block)
|
|||
if (!mir_is_bitwise(ins)) continue;
|
||||
if (ins->invert) continue;
|
||||
|
||||
if (ins->src[0] & IS_REG) continue;
|
||||
if (ins->src[1] & IS_REG) continue;
|
||||
if (!is_ssa_or_constant(ins->src[0])) continue;
|
||||
if (!is_ssa_or_constant(ins->src[1])) continue;
|
||||
if (!mir_single_use(ctx, ins->src[0])) continue;
|
||||
if (!ins->has_inline_constant && !mir_single_use(ctx, ins->src[1])) continue;
|
||||
|
||||
|
|
@ -252,6 +261,10 @@ midgard_opt_fuse_src_invert(compiler_context *ctx, midgard_block *block)
|
|||
unsigned temp = ins->src[0];
|
||||
ins->src[0] = ins->src[1];
|
||||
ins->src[1] = temp;
|
||||
|
||||
temp = ins->alu.src1;
|
||||
ins->alu.src1 = ins->alu.src2;
|
||||
ins->alu.src2 = temp;
|
||||
}
|
||||
|
||||
ins->alu.op = mir_notright_op(ins->alu.op);
|
||||
|
|
|
|||
|
|
@ -231,6 +231,10 @@ mir_use_count(compiler_context *ctx, unsigned value)
|
|||
bool
|
||||
mir_single_use(compiler_context *ctx, unsigned value)
|
||||
{
|
||||
/* We can replicate constants in places so who cares */
|
||||
if (value == SSA_FIXED_REGISTER(REGISTER_CONSTANT))
|
||||
return true;
|
||||
|
||||
return mir_use_count(ctx, value) <= 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue