aco: swap multiplication operands if needed to create v_fmac_f32/etc

For v_pk_fma_f32 and v_fma_f32 from nir_op_ffma, we don't try to put
scalars in the first operand.

No fossil-db changes.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9805>
This commit is contained in:
Rhys Perry 2021-01-13 16:35:01 +00:00 committed by Marge Bot
parent f4f5d577fc
commit c5f02a1cd3
1 changed files with 11 additions and 4 deletions

View File

@ -2580,10 +2580,17 @@ register_allocation(Program* program, std::vector<IDSet>& live_out_per_block, ra
(instr->opcode == aco_opcode::v_pk_fma_f16 && program->chip_class >= GFX10) ||
(instr->opcode == aco_opcode::v_dot4_i32_i8 && program->family != CHIP_VEGA20)) &&
instr->operands[2].isTemp() && instr->operands[2].isKillBeforeDef() &&
instr->operands[2].getTemp().type() == RegType::vgpr && instr->operands[1].isTemp() &&
instr->operands[1].getTemp().type() == RegType::vgpr && !instr->usesModifiers() &&
instr->operands[0].physReg().byte() == 0 && instr->operands[1].physReg().byte() == 0 &&
instr->operands[2].physReg().byte() == 0) {
instr->operands[2].getTemp().type() == RegType::vgpr &&
((instr->operands[0].isTemp() &&
instr->operands[0].getTemp().type() == RegType::vgpr) ||
(instr->operands[1].isTemp() &&
instr->operands[1].getTemp().type() == RegType::vgpr)) &&
!instr->usesModifiers() && instr->operands[0].physReg().byte() == 0 &&
instr->operands[1].physReg().byte() == 0 && instr->operands[2].physReg().byte() == 0) {
if (!instr->operands[1].isTemp() ||
instr->operands[1].getTemp().type() != RegType::vgpr)
std::swap(instr->operands[0], instr->operands[1]);
unsigned def_id = instr->definitions[0].tempId();
bool use_vop2 = true;
if (ctx.assignments[def_id].affinity) {