1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck --check-prefixes=GFX9-NO-BACKOFF %s
3 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx90a -verify-machineinstrs < %s | FileCheck --check-prefixes=GFX9-BACKOFF %s
4 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx940 -verify-machineinstrs < %s | FileCheck --check-prefixes=GFX9-BACKOFF %s
5 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx90a -mattr=-back-off-barrier -verify-machineinstrs < %s | FileCheck --check-prefixes=GFX9-NO-BACKOFF %s
6 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck --check-prefixes=GFX10-BACKOFF %s
7 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -verify-machineinstrs < %s | FileCheck --check-prefixes=GFX11-BACKOFF %s
9 ; Subtargets must wait for outstanding memory instructions before a barrier if
10 ; they cannot back off of the barrier.
12 define void @back_off_barrier_no_fence(ptr %in, ptr %out) #0 {
13 ; GFX9-NO-BACKOFF-LABEL: back_off_barrier_no_fence:
14 ; GFX9-NO-BACKOFF: ; %bb.0:
15 ; GFX9-NO-BACKOFF-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
16 ; GFX9-NO-BACKOFF-NEXT: flat_load_dword v0, v[0:1]
17 ; GFX9-NO-BACKOFF-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
18 ; GFX9-NO-BACKOFF-NEXT: s_barrier
19 ; GFX9-NO-BACKOFF-NEXT: flat_store_dword v[2:3], v0
20 ; GFX9-NO-BACKOFF-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
21 ; GFX9-NO-BACKOFF-NEXT: s_setpc_b64 s[30:31]
23 ; GFX9-BACKOFF-LABEL: back_off_barrier_no_fence:
24 ; GFX9-BACKOFF: ; %bb.0:
25 ; GFX9-BACKOFF-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
26 ; GFX9-BACKOFF-NEXT: flat_load_dword v0, v[0:1]
27 ; GFX9-BACKOFF-NEXT: s_barrier
28 ; GFX9-BACKOFF-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
29 ; GFX9-BACKOFF-NEXT: flat_store_dword v[2:3], v0
30 ; GFX9-BACKOFF-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
31 ; GFX9-BACKOFF-NEXT: s_setpc_b64 s[30:31]
33 ; GFX10-BACKOFF-LABEL: back_off_barrier_no_fence:
34 ; GFX10-BACKOFF: ; %bb.0:
35 ; GFX10-BACKOFF-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
36 ; GFX10-BACKOFF-NEXT: flat_load_dword v0, v[0:1]
37 ; GFX10-BACKOFF-NEXT: s_barrier
38 ; GFX10-BACKOFF-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
39 ; GFX10-BACKOFF-NEXT: flat_store_dword v[2:3], v0
40 ; GFX10-BACKOFF-NEXT: s_waitcnt lgkmcnt(0)
41 ; GFX10-BACKOFF-NEXT: s_setpc_b64 s[30:31]
43 ; GFX11-BACKOFF-LABEL: back_off_barrier_no_fence:
44 ; GFX11-BACKOFF: ; %bb.0:
45 ; GFX11-BACKOFF-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
46 ; GFX11-BACKOFF-NEXT: flat_load_b32 v0, v[0:1]
47 ; GFX11-BACKOFF-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
48 ; GFX11-BACKOFF-NEXT: s_barrier
49 ; GFX11-BACKOFF-NEXT: flat_store_b32 v[2:3], v0
50 ; GFX11-BACKOFF-NEXT: s_waitcnt lgkmcnt(0)
51 ; GFX11-BACKOFF-NEXT: s_setpc_b64 s[30:31]
52 %load = load i32, ptr %in
53 call void @llvm.amdgcn.s.barrier()
54 store i32 %load, ptr %out
58 define void @back_off_barrier_with_fence(ptr %in, ptr %out) #0 {
59 ; GFX9-NO-BACKOFF-LABEL: back_off_barrier_with_fence:
60 ; GFX9-NO-BACKOFF: ; %bb.0:
61 ; GFX9-NO-BACKOFF-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
62 ; GFX9-NO-BACKOFF-NEXT: flat_load_dword v0, v[0:1]
63 ; GFX9-NO-BACKOFF-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
64 ; GFX9-NO-BACKOFF-NEXT: s_barrier
65 ; GFX9-NO-BACKOFF-NEXT: s_waitcnt lgkmcnt(0)
66 ; GFX9-NO-BACKOFF-NEXT: flat_store_dword v[2:3], v0
67 ; GFX9-NO-BACKOFF-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
68 ; GFX9-NO-BACKOFF-NEXT: s_setpc_b64 s[30:31]
70 ; GFX9-BACKOFF-LABEL: back_off_barrier_with_fence:
71 ; GFX9-BACKOFF: ; %bb.0:
72 ; GFX9-BACKOFF-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
73 ; GFX9-BACKOFF-NEXT: flat_load_dword v0, v[0:1]
74 ; GFX9-BACKOFF-NEXT: s_waitcnt lgkmcnt(0)
75 ; GFX9-BACKOFF-NEXT: s_barrier
76 ; GFX9-BACKOFF-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
77 ; GFX9-BACKOFF-NEXT: flat_store_dword v[2:3], v0
78 ; GFX9-BACKOFF-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
79 ; GFX9-BACKOFF-NEXT: s_setpc_b64 s[30:31]
81 ; GFX10-BACKOFF-LABEL: back_off_barrier_with_fence:
82 ; GFX10-BACKOFF: ; %bb.0:
83 ; GFX10-BACKOFF-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
84 ; GFX10-BACKOFF-NEXT: flat_load_dword v0, v[0:1]
85 ; GFX10-BACKOFF-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
86 ; GFX10-BACKOFF-NEXT: s_waitcnt_vscnt null, 0x0
87 ; GFX10-BACKOFF-NEXT: s_barrier
88 ; GFX10-BACKOFF-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
89 ; GFX10-BACKOFF-NEXT: s_waitcnt_vscnt null, 0x0
90 ; GFX10-BACKOFF-NEXT: buffer_gl0_inv
91 ; GFX10-BACKOFF-NEXT: flat_store_dword v[2:3], v0
92 ; GFX10-BACKOFF-NEXT: s_waitcnt lgkmcnt(0)
93 ; GFX10-BACKOFF-NEXT: s_setpc_b64 s[30:31]
95 ; GFX11-BACKOFF-LABEL: back_off_barrier_with_fence:
96 ; GFX11-BACKOFF: ; %bb.0:
97 ; GFX11-BACKOFF-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
98 ; GFX11-BACKOFF-NEXT: flat_load_b32 v0, v[0:1]
99 ; GFX11-BACKOFF-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
100 ; GFX11-BACKOFF-NEXT: s_waitcnt_vscnt null, 0x0
101 ; GFX11-BACKOFF-NEXT: s_barrier
102 ; GFX11-BACKOFF-NEXT: s_waitcnt vmcnt(0) lgkmcnt(0)
103 ; GFX11-BACKOFF-NEXT: s_waitcnt_vscnt null, 0x0
104 ; GFX11-BACKOFF-NEXT: buffer_gl0_inv
105 ; GFX11-BACKOFF-NEXT: flat_store_b32 v[2:3], v0
106 ; GFX11-BACKOFF-NEXT: s_waitcnt lgkmcnt(0)
107 ; GFX11-BACKOFF-NEXT: s_setpc_b64 s[30:31]
108 %load = load i32, ptr %in
109 fence syncscope("workgroup") release
110 call void @llvm.amdgcn.s.barrier()
111 fence syncscope("workgroup") acquire
112 store i32 %load, ptr %out
116 declare void @llvm.amdgcn.s.barrier()
118 attributes #0 = { nounwind }