[PATCH] D37205: AMDGPU: Make worst-case assumption about the wait states in inline assembly
Nicolai Hähnle via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 28 02:56:35 PDT 2017
nhaehnle created this revision.
Herald added subscribers: t-tye, tpr, dstuttard, yaxunl, wdng, kzhuravl.
Mesa still uses a hack where empty inline assembly is used as a kind of
optimization barrier. This exposed a problem where not enough wait states
were inserted, because the hazard recognizer implicitly assumed that each
inline assembly "instruction" has at least one wait state.
https://reviews.llvm.org/D37205
Files:
lib/Target/AMDGPU/GCNHazardRecognizer.cpp
test/CodeGen/AMDGPU/hazard.mir
Index: test/CodeGen/AMDGPU/hazard.mir
===================================================================
--- test/CodeGen/AMDGPU/hazard.mir
+++ test/CodeGen/AMDGPU/hazard.mir
@@ -1,6 +1,7 @@
# RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs -run-pass post-RA-hazard-rec %s -o - | FileCheck -check-prefix=GCN -check-prefix=VI %s
# RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs -run-pass post-RA-hazard-rec %s -o - | FileCheck -check-prefix=GCN -check-prefix=GFX9 %s
+# GCN-LABEL: name: hazard_implicit_def
# GCN: bb.0.entry:
# GCN: %m0 = S_MOV_B32
# GFX9: S_NOP 0
@@ -29,3 +30,31 @@
SI_RETURN_TO_EPILOG killed %vgpr5, killed %vgpr0
...
+
+# GCN-LABEL: name: hazard_inlineasm
+# GCN: bb.0.entry:
+# GCN: %m0 = S_MOV_B32
+# GFX9: S_NOP 0
+# VI-NOT: S_NOP_0
+# GCN: V_INTERP_P1_F32
+---
+name: hazard_inlineasm
+alignment: 0
+exposesReturnsTwice: false
+legalized: false
+regBankSelected: false
+selected: false
+tracksRegLiveness: true
+registers:
+liveins:
+ - { reg: '%sgpr7', virtual-reg: '' }
+ - { reg: '%vgpr4', virtual-reg: '' }
+body: |
+ bb.0.entry:
+ liveins: %sgpr7, %vgpr4
+
+ %m0 = S_MOV_B32 killed %sgpr7
+ INLINEASM $"; no-op", 1, 327690, def %vgpr5
+ %vgpr0 = V_INTERP_P1_F32 killed %vgpr4, 0, 0, implicit %m0, implicit %exec
+ SI_RETURN_TO_EPILOG killed %vgpr5, killed %vgpr0
+...
Index: lib/Target/AMDGPU/GCNHazardRecognizer.cpp
===================================================================
--- lib/Target/AMDGPU/GCNHazardRecognizer.cpp
+++ lib/Target/AMDGPU/GCNHazardRecognizer.cpp
@@ -225,7 +225,8 @@
return WaitStates;
unsigned Opcode = MI->getOpcode();
- if (Opcode == AMDGPU::DBG_VALUE || Opcode == AMDGPU::IMPLICIT_DEF)
+ if (Opcode == AMDGPU::DBG_VALUE || Opcode == AMDGPU::IMPLICIT_DEF ||
+ Opcode == AMDGPU::INLINEASM)
continue;
}
++WaitStates;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37205.112865.patch
Type: text/x-patch
Size: 1959 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170828/4dad5548/attachment.bin>
More information about the llvm-commits
mailing list