Skip to content

Commit de59ec8

Browse files
committed
[AMDGPU] Add verifier for flat_scr_base_hi read hazard
1 parent 1d84c89 commit de59ec8

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed

llvm/lib/Target/AMDGPU/SIInstrInfo.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5808,6 +5808,17 @@ bool SIInstrInfo::verifyInstruction(const MachineInstr &MI,
58085808
}
58095809
}
58105810

5811+
if (ST.hasFlatScratchHiInB64InstHazard() && isSALU(MI) &&
5812+
MI.readsRegister(AMDGPU::SRC_FLAT_SCRATCH_BASE_HI, nullptr)) {
5813+
const MachineOperand *Dst = getNamedOperand(MI, AMDGPU::OpName::sdst);
5814+
if ((Dst && RI.getRegClassForReg(MRI, Dst->getReg()) ==
5815+
&AMDGPU::SReg_64RegClass) ||
5816+
Opcode == AMDGPU::S_BITCMP0_B64 || Opcode == AMDGPU::S_BITCMP1_B64) {
5817+
ErrInfo = "Instruction cannot read flat_scratch_base_hi";
5818+
return false;
5819+
}
5820+
}
5821+
58115822
return true;
58125823
}
58135824

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# RUN: not --crash llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1250 -run-pass=none -filetype=null %s 2>&1 | FileCheck %s
2+
3+
---
4+
name: salu_64_bit_inst_reads_flat_scratch_base_hi
5+
tracksRegLiveness: true
6+
body: |
7+
bb.0:
8+
9+
%0:sreg_64 = IMPLICIT_DEF
10+
$sgpr0_sgpr1 = IMPLICIT_DEF
11+
12+
; CHECK: *** Bad machine code: Instruction cannot read flat_scratch_base_hi ***
13+
; CHECK: S_ASHR_I64
14+
15+
%1:sreg_64 = S_ASHR_I64 %0:sreg_64, $src_flat_scratch_base_hi, implicit-def $scc
16+
17+
; CHECK: *** Bad machine code: Instruction cannot read flat_scratch_base_hi ***
18+
; CHECK: S_LSHL_B64
19+
20+
%2:sreg_64 = S_LSHL_B64 %0:sreg_64, $src_flat_scratch_base_hi, implicit-def $scc
21+
22+
; CHECK: *** Bad machine code: Instruction cannot read flat_scratch_base_hi ***
23+
; CHECK: S_LSHR_B64
24+
25+
%3:sreg_64 = S_LSHR_B64 %0:sreg_64, $src_flat_scratch_base_hi, implicit-def $scc
26+
27+
; CHECK: *** Bad machine code: Instruction cannot read flat_scratch_base_hi ***
28+
; CHECK: S_BFE_I64
29+
30+
%4:sreg_64 = S_BFE_I64 %0:sreg_64, $src_flat_scratch_base_hi, implicit-def $scc
31+
32+
; CHECK: *** Bad machine code: Instruction cannot read flat_scratch_base_hi ***
33+
; CHECK: S_BFE_U64
34+
35+
%5:sreg_64 = S_BFE_U64 %0:sreg_64, $src_flat_scratch_base_hi, implicit-def $scc
36+
37+
; CHECK: *** Bad machine code: Instruction cannot read flat_scratch_base_hi ***
38+
; CHECK: S_BFM_B64
39+
40+
%6:sreg_64 = S_BFM_B64 $src_flat_scratch_base_hi, 1, implicit-def $scc
41+
42+
; CHECK: *** Bad machine code: Instruction cannot read flat_scratch_base_hi ***
43+
; CHECK: S_BITCMP0_B64
44+
45+
S_BITCMP0_B64 %0:sreg_64, $src_flat_scratch_base_hi, implicit $scc, implicit-def $scc
46+
47+
; CHECK: *** Bad machine code: Instruction cannot read flat_scratch_base_hi ***
48+
; CHECK: S_BITCMP1_B64
49+
50+
S_BITCMP1_B64 %0:sreg_64, $src_flat_scratch_base_hi, implicit $scc, implicit-def $scc
51+
52+
; CHECK: *** Bad machine code: Instruction cannot read flat_scratch_base_hi ***
53+
; CHECK: S_BITREPLICATE_B64_B32
54+
55+
%7:sreg_64 = S_BITREPLICATE_B64_B32 $src_flat_scratch_base_hi, implicit-def $scc
56+
57+
; CHECK: *** Bad machine code: Instruction cannot read flat_scratch_base_hi ***
58+
; CHECK: S_BITSET0_B64
59+
60+
$sgpr0_sgpr1 = S_BITSET0_B64 $src_flat_scratch_base_hi, $sgpr0_sgpr1, implicit-def $scc
61+
62+
; CHECK: *** Bad machine code: Instruction cannot read flat_scratch_base_hi ***
63+
; CHECK: S_BITSET1_B64
64+
65+
$sgpr0_sgpr1 = S_BITSET1_B64 $src_flat_scratch_base_hi, $sgpr0_sgpr1, implicit-def $scc
66+
...

0 commit comments

Comments
 (0)