]> granicus.if.org Git - llvm/commitdiff
AMDGPU: Don't track lgkmcnt for global_/scratch_ instructions
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Fri, 21 Jul 2017 18:34:51 +0000 (18:34 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Fri, 21 Jul 2017 18:34:51 +0000 (18:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308766 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AMDGPU/FLATInstructions.td
lib/Target/AMDGPU/SIInsertWaitcnts.cpp
lib/Target/AMDGPU/SIInstrInfo.h

index c886e49af288b3d0a91e02a2471e0e4fc7db17b8..fcfd629d55e1e9a7749c33e4fe33faf17d995b27 100644 (file)
@@ -25,11 +25,6 @@ class FLAT_Pseudo<string opName, dag outs, dag ins,
   let SubtargetPredicate = isCIVI;
 
   let FLAT = 1;
-  // Internally, FLAT instruction are executed as both an LDS and a
-  // Buffer instruction; so, they increment both VM_CNT and LGKM_CNT
-  // and are not considered done until both have been decremented.
-  let VM_CNT = 1;
-  let LGKM_CNT = 1;
 
   let UseNamedOperandTable = 1;
   let hasSideEffects = 0;
@@ -59,6 +54,12 @@ class FLAT_Pseudo<string opName, dag outs, dag ins,
 
   // TODO: M0 if it could possibly access LDS (before gfx9? only)?
   let Uses = !if(is_flat_global, [EXEC], [EXEC, FLAT_SCR]);
+
+  // Internally, FLAT instruction are executed as both an LDS and a
+  // Buffer instruction; so, they increment both VM_CNT and LGKM_CNT
+  // and are not considered done until both have been decremented.
+  let VM_CNT = 1;
+  let LGKM_CNT = !if(!or(is_flat_global, is_flat_scratch), 0, 1);
 }
 
 class FLAT_Real <bits<7> op, FLAT_Pseudo ps> :
index 0f009a48754adba6c1dd464d5d22cebb118918f4..89b597240eb66afaf02fd1fbfd012c4558c7aa0b 100644 (file)
@@ -1151,8 +1151,7 @@ void SIInsertWaitcnts::updateEventWaitCntAfter(
   // instruction, update the upper-bound of the appropriate counter's
   // bracket and the destination operand scores.
   // TODO: Use the (TSFlags & SIInstrFlags::LGKM_CNT) property everywhere.
-  uint64_t TSFlags = Inst.getDesc().TSFlags;
-  if (TII->isDS(Inst) && (TSFlags & SIInstrFlags::LGKM_CNT)) {
+  if (TII->isDS(Inst) && TII->usesLGKM_CNT(Inst)) {
     if (TII->getNamedOperand(Inst, AMDGPU::OpName::gds) &&
        TII->getNamedOperand(Inst, AMDGPU::OpName::gds)->getImm() != 0) {
       ScoreBrackets->updateByEvent(TII, TRI, MRI, GDS_ACCESS, Inst);
@@ -1162,8 +1161,12 @@ void SIInsertWaitcnts::updateEventWaitCntAfter(
     }
   } else if (TII->isFLAT(Inst)) {
     assert(Inst.mayLoad() || Inst.mayStore());
-    ScoreBrackets->updateByEvent(TII, TRI, MRI, VMEM_ACCESS, Inst);
-    ScoreBrackets->updateByEvent(TII, TRI, MRI, LDS_ACCESS, Inst);
+
+    if (TII->usesVM_CNT(Inst))
+      ScoreBrackets->updateByEvent(TII, TRI, MRI, VMEM_ACCESS, Inst);
+
+    if (TII->usesLGKM_CNT(Inst))
+      ScoreBrackets->updateByEvent(TII, TRI, MRI, LDS_ACCESS, Inst);
 
     // This is a flat memory operation. Check to see if it has memory
     // tokens for both LDS and Memory, and if so mark it as a flat.
index 3dd5bc89e6c77baa87ad89af34f93fada7553589..57a5133e0edbe1321803399bf5f65615afb41b4f 100644 (file)
@@ -496,6 +496,10 @@ public:
     return MI.getDesc().TSFlags & SIInstrFlags::VM_CNT;
   }
 
+  static bool usesLGKM_CNT(const MachineInstr &MI) {
+    return MI.getDesc().TSFlags & SIInstrFlags::LGKM_CNT;
+  }
+
   static bool sopkIsZext(const MachineInstr &MI) {
     return MI.getDesc().TSFlags & SIInstrFlags::SOPK_ZEXT;
   }