diff --git a/src/amd/compiler/aco_optimizer.cpp b/src/amd/compiler/aco_optimizer.cpp index a6d1a60415a..885ffc54bb4 100644 --- a/src/amd/compiler/aco_optimizer.cpp +++ b/src/amd/compiler/aco_optimizer.cpp @@ -4819,6 +4819,13 @@ select_instruction(opt_ctx& ctx, aco_ptr& instr) if (!info.is_dpp() || info.instr->pass_flags != instr->pass_flags) continue; + /* We won't eliminate the DPP mov if the operand is used twice */ + bool op_used_twice = false; + for (unsigned j = 0; j < instr->operands.size(); j++) + op_used_twice |= i != j && instr->operands[i] == instr->operands[j]; + if (op_used_twice) + continue; + if (i != 0) { if (!can_swap_operands(instr, &instr->opcode, 0, i)) continue; diff --git a/src/amd/compiler/aco_optimizer_postRA.cpp b/src/amd/compiler/aco_optimizer_postRA.cpp index e8d593915f2..d04b3c6c0f6 100644 --- a/src/amd/compiler/aco_optimizer_postRA.cpp +++ b/src/amd/compiler/aco_optimizer_postRA.cpp @@ -505,6 +505,13 @@ try_combine_dpp(pr_opt_ctx& ctx, aco_ptr& instr) if (is_overwritten_since(ctx, mov->operands[0], op_instr_idx)) continue; + /* We won't eliminate the DPP mov if the operand is used twice */ + bool op_used_twice = false; + for (unsigned j = 0; j < instr->operands.size(); j++) + op_used_twice |= i != j && instr->operands[i] == instr->operands[j]; + if (op_used_twice) + continue; + bool dpp8 = mov->isDPP8(); bool input_mods = instr_info.can_use_input_modifiers[(int)instr->opcode] && instr_info.operand_size[(int)instr->opcode] == 32;