Skip to content

Commit

Permalink
[AMDGPU] Don't combine DPP if DPP register is used more than once per…
Browse files Browse the repository at this point in the history
… instruction

  Modified for cherry-pick into amd-mainline-open: removed references to MODE registers in llvm/test/CodeGen/AMDGPU/dpp_combine.mir

Reviewers: arsenm, rampitec, foad

Reviewed By: rampitec, foad

Subscribers: wuzish, kzhuravl, nemanjai, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, hiraditya, kbarton, kerbowa, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D82551

Change-Id: Ie8334c8e5d2016bed716a618653a87e50b6ac241
  • Loading branch information
vpykhtin committed Jul 16, 2020
1 parent 9a2128b commit 3c7cef4
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions llvm/lib/Target/AMDGPU/GCNDPPCombine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,15 +506,32 @@ bool GCNDPPCombine::combineDPPMov(MachineInstr &MovMI) const {
break;
}

auto *Src0 = TII->getNamedOperand(OrigMI, AMDGPU::OpName::src0);
auto *Src1 = TII->getNamedOperand(OrigMI, AMDGPU::OpName::src1);
if (Use != Src0 && !(Use == Src1 && OrigMI.isCommutable())) { // [1]
LLVM_DEBUG(dbgs() << " failed: no suitable operands\n");
break;
}

assert(Src0 && "Src1 without Src0?");
if (Src1 && Src1->isIdenticalTo(*Src0)) {
assert(Src1->isReg());
LLVM_DEBUG(
dbgs()
<< " " << OrigMI
<< " failed: DPP register is used more than once per instruction\n");
break;
}

LLVM_DEBUG(dbgs() << " combining: " << OrigMI);
if (Use == TII->getNamedOperand(OrigMI, AMDGPU::OpName::src0)) {
if (Use == Src0) {
if (auto *DPPInst = createDPPInst(OrigMI, MovMI, CombOldVGPR,
OldOpndValue, CombBCZ)) {
DPPMIs.push_back(DPPInst);
Rollback = false;
}
} else if (OrigMI.isCommutable() &&
Use == TII->getNamedOperand(OrigMI, AMDGPU::OpName::src1)) {
} else {
assert(Use == Src1 && OrigMI.isCommutable()); // by check [1]
auto *BB = OrigMI.getParent();
auto *NewMI = BB->getParent()->CloneMachineInstr(&OrigMI);
BB->insert(OrigMI, NewMI);
Expand All @@ -528,8 +545,7 @@ bool GCNDPPCombine::combineDPPMov(MachineInstr &MovMI) const {
} else
LLVM_DEBUG(dbgs() << " failed: cannot be commuted\n");
NewMI->eraseFromParent();
} else
LLVM_DEBUG(dbgs() << " failed: no suitable operands\n");
}
if (Rollback)
break;
OrigMIs.push_back(&OrigMI);
Expand Down

0 comments on commit 3c7cef4

Please sign in to comment.