R600/SI: Insert s_waitcnt before s_barrier instructions.
authorTom Stellard <thomas.stellard@amd.com>
Tue, 6 Jan 2015 19:52:07 +0000 (19:52 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Tue, 6 Jan 2015 19:52:07 +0000 (19:52 +0000)
This ensures that all memory operations are complete when all threads
reach the barrier.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225290 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/R600/SIInsertWaits.cpp
test/CodeGen/R600/llvm.AMDGPU.barrier.global.ll
test/CodeGen/R600/llvm.AMDGPU.barrier.local.ll

index 2e56508e2fae33856878ef20cbd70da32206ce79..181b11643bf3e87cdf5028a49ffc6fe42583bd58 100644 (file)
@@ -428,7 +428,11 @@ bool SIInsertWaits::runOnMachineFunction(MachineFunction &MF) {
     for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end();
          I != E; ++I) {
 
-      Changes |= insertWait(MBB, I, handleOperands(*I));
+      // Wait for everything before a barrier.
+      if (I->getOpcode() == AMDGPU::S_BARRIER)
+        Changes |= insertWait(MBB, I, LastIssued);
+      else
+        Changes |= insertWait(MBB, I, handleOperands(*I));
       pushInstruction(MBB, I);
     }
 
index 31e170948a0a2fcbaf48099405262b42655641ae..a11d9ae7af08f3221e9e8828894ef5a42e1d130c 100644 (file)
@@ -3,6 +3,8 @@
 
 ; FUNC-LABEL: {{^}}test_barrier_global:
 ; EG: GROUP_BARRIER
+; SI: buffer_store_dword
+; SI: s_waitcnt
 ; SI: s_barrier
 
 define void @test_barrier_global(i32 addrspace(1)* %out) {
index 94b3cbc86eb0b5bbf6e2c681c2b01b223700d0be..76c2453d089f30550836e72714b9d771e546216f 100644 (file)
@@ -3,6 +3,9 @@
 
 ; FUNC-LABEL: {{^}}test_barrier_local:
 ; EG: GROUP_BARRIER
+
+; SI: buffer_store_dword
+; SI: s_waitcnt
 ; SI: s_barrier
 
 define void @test_barrier_local(i32 addrspace(1)* %out) {