From 60f3f0fdbb22835c040a483c8a7ad6d63d2bc6ec Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Thu, 6 Jun 2024 11:26:07 +0200 Subject: [PATCH] aco/ra: use a switch to check vop2acc instruction support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_register_allocation.cpp | 32 ++++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp index ac623d4239e..06a24507239 100644 --- a/src/amd/compiler/aco_register_allocation.cpp +++ b/src/amd/compiler/aco_register_allocation.cpp @@ -2554,15 +2554,29 @@ vop3_can_use_vop2acc(ra_ctx& ctx, Instruction* instr) if (!instr->isVOP3() && !instr->isVOP3P()) return false; - if ((instr->opcode != aco_opcode::v_mad_f32 && - (instr->opcode != aco_opcode::v_fma_f32 || ctx.program->gfx_level < GFX10) && - instr->opcode != aco_opcode::v_mad_f16 && instr->opcode != aco_opcode::v_mad_legacy_f16 && - (instr->opcode != aco_opcode::v_fma_f16 || ctx.program->gfx_level < GFX10) && - (instr->opcode != aco_opcode::v_pk_fma_f16 || ctx.program->gfx_level < GFX10) && - (instr->opcode != aco_opcode::v_mad_legacy_f32 || !ctx.program->dev.has_mac_legacy32) && - (instr->opcode != aco_opcode::v_fma_legacy_f32 || !ctx.program->dev.has_fmac_legacy32) && - (instr->opcode != aco_opcode::v_dot4_i32_i8 || ctx.program->family == CHIP_VEGA20)) || - !instr->operands[2].isOfType(RegType::vgpr) || !instr->operands[2].isKillBeforeDef() || + switch (instr->opcode) { + case aco_opcode::v_mad_f32: + case aco_opcode::v_mad_f16: + case aco_opcode::v_mad_legacy_f16: break; + case aco_opcode::v_fma_f32: + case aco_opcode::v_pk_fma_f16: + case aco_opcode::v_fma_f16: + case aco_opcode::v_dot4_i32_i8: + if (ctx.program->gfx_level < GFX10) + return false; + break; + case aco_opcode::v_mad_legacy_f32: + if (!ctx.program->dev.has_mac_legacy32) + return false; + break; + case aco_opcode::v_fma_legacy_f32: + if (!ctx.program->dev.has_fmac_legacy32) + return false; + break; + default: return false; + } + + if (!instr->operands[2].isOfType(RegType::vgpr) || !instr->operands[2].isKillBeforeDef() || (!instr->operands[0].isOfType(RegType::vgpr) && !instr->operands[1].isOfType(RegType::vgpr))) return false;