[PATCH] D130783: [AMDGPU] Extend cases for ReadM0MovRelInterpHazard
Piotr Sobczak via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 29 08:59:50 PDT 2022
piotr created this revision.
Herald added subscribers: kosarev, jsilvanus, foad, kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl, arsenm.
Herald added a project: All.
piotr requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.
Extend hazard recognizer of ReadM0MovRelInterpHazard with
DS_READ_ADDTID and DS_WRITE_ADDTID, as they also
require a manually inserted S_NOP after SALU writing m0.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D130783
Files:
llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
llvm/test/CodeGen/AMDGPU/hazard-lds-addtid.mir
Index: llvm/test/CodeGen/AMDGPU/hazard-lds-addtid.mir
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/AMDGPU/hazard-lds-addtid.mir
@@ -0,0 +1,52 @@
+# RUN: llc -march=amdgcn -mcpu=gfx900 -run-pass post-RA-hazard-rec %s -o - | FileCheck %s -check-prefixes=GCN,GFX9
+# RUN: llc -march=amdgcn -mcpu=gfx1010 -run-pass post-RA-hazard-rec %s -o - | FileCheck %s -check-prefixes=GCN
+# RUN: llc -march=amdgcn -mcpu=gfx1100 -run-pass post-RA-hazard-rec %s -o - | FileCheck %s -check-prefixes=GCN
+---
+
+# GCN-LABEL: name: addtid
+
+# GCN-LABEL: bb.0:
+# GCN: S_MOV_B32
+# GFX9: S_NOP
+# GCN-NEXT: DS_WRITE_ADDTID_B32
+
+# GCN-LABEL: bb.1:
+# GCN: S_MOV_B32
+# GFX9: S_NOP
+# GCN-NEXT: DS_READ_ADDTID_B32
+
+# GCN-LABEL: bb.2:
+# GCN: S_MOV_B32
+# GFX9: S_NOP
+# GCN-NEXT: DS_WRITE_ADDTID_B32
+
+# GCN-LABEL: bb.3:
+# GCN: S_MOV_B32
+# GFX9: S_NOP
+# GCN-NEXT: DS_READ_ADDTID_B32
+
+name: addtid
+
+body: |
+ bb.0:
+ $m0 = S_MOV_B32 0
+ DS_WRITE_ADDTID_B32 killed $vgpr0, 0, 0, implicit $m0, implicit $exec
+ S_BRANCH %bb.1
+
+ bb.1:
+ $m0 = S_MOV_B32 0
+ $vgpr0 = DS_READ_ADDTID_B32 0, 0, implicit $m0, implicit $exec
+ S_BRANCH %bb.2
+
+ bb.2:
+ $m0 = S_MOV_B32 0
+ DS_WRITE_ADDTID_B32 killed $vgpr0, 0, 0, implicit $m0, implicit $exec
+ S_BRANCH %bb.3
+
+ bb.3:
+ $m0 = S_MOV_B32 0
+ $vgpr0 = DS_READ_ADDTID_B32 0, 0, implicit $m0, implicit $exec
+ S_ENDPGM 0
+...
+
+...
Index: llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
+++ llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp
@@ -230,9 +230,10 @@
if (isRFE(MI->getOpcode()) && checkRFEHazards(MI) > 0)
return HazardType;
-
if (((ST.hasReadM0MovRelInterpHazard() &&
- (TII.isVINTRP(*MI) || isSMovRel(MI->getOpcode()))) ||
+ (TII.isVINTRP(*MI) || isSMovRel(MI->getOpcode()) ||
+ MI->getOpcode() == AMDGPU::DS_WRITE_ADDTID_B32 ||
+ MI->getOpcode() == AMDGPU::DS_READ_ADDTID_B32)) ||
(ST.hasReadM0SendMsgHazard() && isSendMsgTraceDataOrGDS(TII, *MI)) ||
(ST.hasReadM0LdsDmaHazard() && isLdsDma(*MI)) ||
(ST.hasReadM0LdsDirectHazard() &&
@@ -357,7 +358,9 @@
return std::max(WaitStates, checkRFEHazards(MI));
if ((ST.hasReadM0MovRelInterpHazard() &&
- (TII.isVINTRP(*MI) || isSMovRel(MI->getOpcode()))) ||
+ (TII.isVINTRP(*MI) || isSMovRel(MI->getOpcode()) ||
+ MI->getOpcode() == AMDGPU::DS_WRITE_ADDTID_B32 ||
+ MI->getOpcode() == AMDGPU::DS_READ_ADDTID_B32)) ||
(ST.hasReadM0SendMsgHazard() && isSendMsgTraceDataOrGDS(TII, *MI)) ||
(ST.hasReadM0LdsDmaHazard() && isLdsDma(*MI)) ||
(ST.hasReadM0LdsDirectHazard() && MI->readsRegister(AMDGPU::LDS_DIRECT)))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130783.448647.patch
Type: text/x-patch
Size: 2840 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220729/9a8f0790/attachment.bin>
More information about the llvm-commits
mailing list