Skip to content

Commit c9c18e5

Browse files
committed
[AMDGPU] Disallow dpp combining for dpp instructions without Src2 operand (when Src2 is required)
Differential revision: https://reviews.llvm.org/D69430
1 parent 0877dd1 commit c9c18e5

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

llvm/lib/Target/AMDGPU/GCNDPPCombine.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ MachineInstr *GCNDPPCombine::createDPPInst(MachineInstr &OrigMI,
235235
}
236236

237237
if (auto *Src2 = TII->getNamedOperand(OrigMI, AMDGPU::OpName::src2)) {
238-
if (!TII->isOperandLegal(*DPPInst.getInstr(), NumOperands, Src2)) {
238+
if (!TII->getNamedOperand(*DPPInst.getInstr(), AMDGPU::OpName::src2) ||
239+
!TII->isOperandLegal(*DPPInst.getInstr(), NumOperands, Src2)) {
239240
LLVM_DEBUG(dbgs() << " failed: src2 is illegal\n");
240241
Fail = true;
241242
break;

llvm/test/CodeGen/AMDGPU/dpp_combine.mir

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,3 +794,19 @@ body: |
794794
%4:vgpr_32 = V_ADD_I32_e32 %2.sub0, undef %3:vgpr_32, implicit-def $vcc, implicit $exec
795795
%5:vgpr_32, dead %6:sreg_64_xexec = V_ADDC_U32_e64 1, %2.sub1, undef $vcc, 0, implicit $exec
796796
...
797+
798+
# GCN-LABEL: name: dont_combine_cndmask_with_src2
799+
# GCN: %5:vgpr_32 = V_CNDMASK_B32_e64 0, %3, 0, %1, %4, implicit $exec
800+
name: dont_combine_cndmask_with_src2
801+
tracksRegLiveness: true
802+
body: |
803+
bb.0:
804+
liveins: $vgpr0, $vgpr1
805+
%0:vgpr_32 = COPY $vgpr0
806+
%1:vgpr_32 = COPY $vgpr1
807+
%2:vgpr_32 = IMPLICIT_DEF
808+
809+
%3:vgpr_32 = V_MOV_B32_dpp %2, %0, 1, 15, 15, 1, implicit $exec
810+
%4:sreg_64_xexec = IMPLICIT_DEF
811+
%5:vgpr_32 = V_CNDMASK_B32_e64 0, %3, 0, %1, %4, implicit $exec
812+
...

0 commit comments

Comments
 (0)