aco: undo operand swap if applying DPP fails

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39516>
This commit is contained in:
Georg Lehmann 2026-01-25 15:23:34 +01:00 committed by Marge Bot
parent 531228159f
commit 8ac7b9fc37
2 changed files with 21 additions and 9 deletions

View file

@ -4975,21 +4975,27 @@ select_instruction(opt_ctx& ctx, aco_ptr<Instruction>& instr)
if (op_used_twice)
continue;
bool dpp8 = info.parent_instr->isDPP8();
bool input_mods = can_use_input_modifiers(ctx.program->gfx_level, instr->opcode, i) &&
get_operand_type(instr, i).bit_size == 32;
bool mov_uses_mods = info.parent_instr->valu().neg[0] || info.parent_instr->valu().abs[0];
if (((dpp8 && ctx.program->gfx_level < GFX11) || !input_mods) && mov_uses_mods)
continue;
if (i != 0) {
if (!can_swap_operands(instr, &instr->opcode, 0, i))
continue;
instr->valu().swapOperands(0, i);
}
bool dpp8 = info.parent_instr->isDPP8();
if (!can_use_DPP(ctx.program->gfx_level, instr, dpp8))
continue;
bool input_mods = can_use_input_modifiers(ctx.program->gfx_level, instr->opcode, 0) &&
get_operand_type(instr, 0).bit_size == 32;
bool mov_uses_mods = info.parent_instr->valu().neg[0] || info.parent_instr->valu().abs[0];
if (((dpp8 && ctx.program->gfx_level < GFX11) || !input_mods) && mov_uses_mods)
if (!can_use_DPP(ctx.program->gfx_level, instr, dpp8)) {
if (i != 0) {
ASSERTED bool success = can_swap_operands(instr, &instr->opcode, 0, i);
assert(success);
instr->valu().swapOperands(0, i);
}
continue;
}
convert_to_DPP(ctx.program->gfx_level, instr, dpp8);

View file

@ -649,8 +649,14 @@ try_combine_dpp(pr_opt_ctx& ctx, aco_ptr<Instruction>& instr)
instr->valu().swapOperands(0, i);
}
if (!can_use_DPP(ctx.program->gfx_level, instr, dpp8))
if (!can_use_DPP(ctx.program->gfx_level, instr, dpp8)) {
if (i != 0) {
ASSERTED bool success = can_swap_operands(instr, &instr->opcode, 0, i);
assert(success);
instr->valu().swapOperands(0, i);
}
continue;
}
if (!dpp8) /* anything else doesn't make sense in SSA */
assert(mov->dpp16().row_mask == 0xf && mov->dpp16().bank_mask == 0xf);