Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 164431e

Browse files
committed
Merging r312337:
------------------------------------------------------------------------ r312337 | nha | 2017-09-01 09:56:32 -0700 (Fri, 01 Sep 2017) | 12 lines AMDGPU: IMPLICIT_DEFs and DBG_VALUEs do not contribute to wait states Summary: This fixes a bug that was exposed on gfx9 in various GL45-CTS.shaders.loops.*_iterations.select_iteration_count_fragment tests, e.g. GL45-CTS.shaders.loops.do_while_uniform_iterations.select_iteration_count_fragment Reviewers: arsenm Subscribers: kzhuravl, wdng, yaxunl, dstuttard, tpr, t-tye, llvm-commits Differential Revision: https://reviews.llvm.org/D36193 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_50@314327 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent b34136e commit 164431e

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

lib/Target/AMDGPU/GCNHazardRecognizer.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,17 @@ void GCNHazardRecognizer::RecedeCycle() {
218218

219219
int GCNHazardRecognizer::getWaitStatesSince(
220220
function_ref<bool(MachineInstr *)> IsHazard) {
221-
int WaitStates = -1;
221+
int WaitStates = 0;
222222
for (MachineInstr *MI : EmittedInstrs) {
223+
if (MI) {
224+
if (IsHazard(MI))
225+
return WaitStates;
226+
227+
unsigned Opcode = MI->getOpcode();
228+
if (Opcode == AMDGPU::DBG_VALUE || Opcode == AMDGPU::IMPLICIT_DEF)
229+
continue;
230+
}
223231
++WaitStates;
224-
if (!MI || !IsHazard(MI))
225-
continue;
226-
return WaitStates;
227232
}
228233
return std::numeric_limits<int>::max();
229234
}

test/CodeGen/AMDGPU/hazard.mir

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs -run-pass post-RA-hazard-rec %s -o - | FileCheck -check-prefix=GCN -check-prefix=VI %s
2+
# RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs -run-pass post-RA-hazard-rec %s -o - | FileCheck -check-prefix=GCN -check-prefix=GFX9 %s
3+
4+
# GCN: bb.0.entry:
5+
# GCN: %m0 = S_MOV_B32
6+
# GFX9: S_NOP 0
7+
# VI-NOT: S_NOP_0
8+
# GCN: V_INTERP_P1_F32
9+
10+
---
11+
name: hazard_implicit_def
12+
alignment: 0
13+
exposesReturnsTwice: false
14+
legalized: false
15+
regBankSelected: false
16+
selected: false
17+
tracksRegLiveness: true
18+
registers:
19+
liveins:
20+
- { reg: '%sgpr7', virtual-reg: '' }
21+
- { reg: '%vgpr4', virtual-reg: '' }
22+
body: |
23+
bb.0.entry:
24+
liveins: %sgpr7, %vgpr4
25+
26+
%m0 = S_MOV_B32 killed %sgpr7
27+
%vgpr5 = IMPLICIT_DEF
28+
%vgpr0 = V_INTERP_P1_F32 killed %vgpr4, 0, 0, implicit %m0, implicit %exec
29+
SI_RETURN_TO_EPILOG killed %vgpr5, killed %vgpr0
30+
31+
...

0 commit comments

Comments
 (0)