Skip to content

Commit 33d12e6

Browse files
[AMDGPU] Fix dpp src1 sgpr
#67461 enabled SGPRs as src1 by default for all opcodes with manual checks for targets where this is not supported. #155595 disabled this check for hasDPPSrc1SGPR, which resulted in SGPRs being used as operands on gfx11. This PR reenables this check and fixes the corresponding lit test.
1 parent 40c917f commit 33d12e6

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

llvm/lib/Target/AMDGPU/GCNDPPCombine.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,12 @@ MachineInstr *GCNDPPCombine::createDPPInst(MachineInstr &OrigMI,
307307
if (Src1) {
308308
assert(AMDGPU::hasNamedOperand(DPPOp, AMDGPU::OpName::src1) &&
309309
"dpp version of instruction missing src1");
310-
// If subtarget does not support SGPRs for src1 operand then the
311-
// requirements are the same as for src0. We check src0 instead because
312-
// pseudos are shared between subtargets and allow SGPR for src1 on all.
313310
if (!ST->hasDPPSrc1SGPR()) {
311+
if (Src1->isReg() && ST->getRegisterInfo()->isSGPRClass(
312+
MRI->getRegClass(Src1->getReg()))) {
313+
Fail = true;
314+
break;
315+
}
314316
assert(TII->getOpSize(*DPPInst, Src0Idx) ==
315317
TII->getOpSize(*DPPInst, NumOperands) &&
316318
"Src0 and Src1 operands should have the same size");

llvm/test/CodeGen/AMDGPU/dpp_combine_gfx11.mir

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# RUN: llc -mtriple=amdgcn -mcpu=gfx1100 -mattr=-real-true16 -run-pass=gcn-dpp-combine -verify-machineinstrs -o - %s | FileCheck %s -check-prefixes=GCN
2-
# RUN: llc -mtriple=amdgcn -mcpu=gfx1150 -mattr=-real-true16 -run-pass=gcn-dpp-combine -verify-machineinstrs -o - %s | FileCheck %s -check-prefixes=GCN
3-
# RUN: llc -mtriple=amdgcn -mcpu=gfx1200 -mattr=-real-true16 -run-pass=gcn-dpp-combine -verify-machineinstrs -o - %s | FileCheck %s -check-prefixes=GCN
1+
# RUN: llc -mtriple=amdgcn -mcpu=gfx1100 -mattr=-real-true16 -run-pass=gcn-dpp-combine -verify-machineinstrs -o - %s | FileCheck %s -check-prefixes=GCN,GFX1100
2+
# RUN: llc -mtriple=amdgcn -mcpu=gfx1150 -mattr=-real-true16 -run-pass=gcn-dpp-combine -verify-machineinstrs -o - %s | FileCheck %s -check-prefixes=GCN,GFX1150
3+
# RUN: llc -mtriple=amdgcn -mcpu=gfx1200 -mattr=-real-true16 -run-pass=gcn-dpp-combine -verify-machineinstrs -o - %s | FileCheck %s -check-prefixes=GCN,GFX1150
44

55
---
66

@@ -38,8 +38,10 @@ body: |
3838

3939
# GCN-LABEL: name: vop3_sgpr_src1
4040
# GCN: %6:vgpr_32 = V_MED3_F32_e64_dpp %4, 0, %0, 0, %1, 0, %2, 0, 0, 1, 15, 15, 1, implicit $mode, implicit $exec
41-
# GCN: %8:vgpr_32 = V_MED3_F32_e64_dpp %4, 0, %0, 0, %2, 0, %1, 0, 0, 1, 15, 15, 1, implicit $mode, implicit $exec
42-
# GCN: %10:vgpr_32 = V_MED3_F32_e64_dpp %4, 0, %0, 0, %2, 0, %3, 0, 0, 1, 15, 15, 1, implicit $mode, implicit $exec
41+
# GFX1100: %8:vgpr_32 = V_MED3_F32_e64 0, %7, 0, %2, 0, %1, 0, 0, implicit $mode, implicit $exec
42+
# GFX1150: %8:vgpr_32 = V_MED3_F32_e64_dpp %4, 0, %0, 0, %2, 0, %1, 0, 0, 1, 15, 15, 1, implicit $mode, implicit $exec
43+
# GFX1100: %10:vgpr_32 = V_MED3_F32_e64 0, %9, 0, %2, 0, %3, 0, 0, implicit $mode, implicit $exec
44+
# GFX1150: %10:vgpr_32 = V_MED3_F32_e64_dpp %4, 0, %0, 0, %2, 0, %3, 0, 0, 1, 15, 15, 1, implicit $mode, implicit $exec
4345
# GCN: %12:vgpr_32 = V_MED3_F32_e64_dpp %4, 0, %0, 0, 42, 0, %2, 0, 0, 1, 15, 15, 1, implicit $mode, implicit $exec
4446
# GCN: %14:vgpr_32 = V_MED3_F32_e64 0, %13, 0, 4242, 0, %2, 0, 0, implicit $mode, implicit $exec
4547
name: vop3_sgpr_src1

0 commit comments

Comments
 (0)