annotate llvm/test/CodeGen/AMDGPU/llvm.amdgcn.raw.buffer.atomic.ll @ 266:00f31e85ec16 default tip

Added tag current for changeset 31d058e83c98
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 14 Oct 2023 10:13:55 +0900
parents 1f2b6ac9f198
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 221
diff changeset
1 ;RUN: llc < %s -march=amdgcn -mcpu=verde -amdgpu-atomic-optimizer-strategy=None -verify-machineinstrs | FileCheck %s
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 221
diff changeset
2 ;RUN: llc < %s -march=amdgcn -mcpu=tonga -amdgpu-atomic-optimizer-strategy=None -verify-machineinstrs | FileCheck %s
150
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 ;CHECK-LABEL: {{^}}test1:
anatofuz
parents:
diff changeset
5 ;CHECK-NOT: s_waitcnt
anatofuz
parents:
diff changeset
6 ;CHECK: buffer_atomic_swap v0, off, s[0:3], 0 glc
anatofuz
parents:
diff changeset
7 ;CHECK: s_movk_i32 [[SOFS:s[0-9]+]], 0x1ffc
anatofuz
parents:
diff changeset
8 ;CHECK: s_waitcnt vmcnt(0)
anatofuz
parents:
diff changeset
9 ;CHECK: buffer_atomic_swap v0, v1, s[0:3], 0 offen glc
anatofuz
parents:
diff changeset
10 ;CHECK: s_waitcnt vmcnt(0)
anatofuz
parents:
diff changeset
11 ;CHECK: buffer_atomic_swap v0, v1, s[0:3], 0 offen offset:42 glc
anatofuz
parents:
diff changeset
12 ;CHECK-DAG: s_waitcnt vmcnt(0)
anatofuz
parents:
diff changeset
13 ;CHECK: buffer_atomic_swap v0, off, s[0:3], [[SOFS]] offset:4 glc
anatofuz
parents:
diff changeset
14 ;CHECK: s_waitcnt vmcnt(0)
anatofuz
parents:
diff changeset
15 ;CHECK: buffer_atomic_swap v0, off, s[0:3], 0{{$}}
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
16 ;CHECK: buffer_atomic_swap v0, off, s[0:3], 0 glc
150
anatofuz
parents:
diff changeset
17 define amdgpu_ps float @test1(<4 x i32> inreg %rsrc, i32 %data, i32 %voffset) {
anatofuz
parents:
diff changeset
18 main_body:
anatofuz
parents:
diff changeset
19 %o1 = call i32 @llvm.amdgcn.raw.buffer.atomic.swap.i32(i32 %data, <4 x i32> %rsrc, i32 0, i32 0, i32 0)
anatofuz
parents:
diff changeset
20 %o3 = call i32 @llvm.amdgcn.raw.buffer.atomic.swap.i32(i32 %o1, <4 x i32> %rsrc, i32 %voffset, i32 0, i32 0)
anatofuz
parents:
diff changeset
21 %off5 = add i32 %voffset, 42
anatofuz
parents:
diff changeset
22 %o5 = call i32 @llvm.amdgcn.raw.buffer.atomic.swap.i32(i32 %o3, <4 x i32> %rsrc, i32 %off5, i32 0, i32 0)
anatofuz
parents:
diff changeset
23 %o6 = call i32 @llvm.amdgcn.raw.buffer.atomic.swap.i32(i32 %o5, <4 x i32> %rsrc, i32 4, i32 8188, i32 0)
anatofuz
parents:
diff changeset
24 %unused = call i32 @llvm.amdgcn.raw.buffer.atomic.swap.i32(i32 %o6, <4 x i32> %rsrc, i32 0, i32 0, i32 0)
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
25 %o7 = bitcast i32 %o6 to float
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
26 %out = call float @llvm.amdgcn.raw.buffer.atomic.swap.f32(float %o7, <4 x i32> %rsrc, i32 0, i32 0, i32 0)
150
anatofuz
parents:
diff changeset
27 ret float %out
anatofuz
parents:
diff changeset
28 }
anatofuz
parents:
diff changeset
29
anatofuz
parents:
diff changeset
30 ;CHECK-LABEL: {{^}}test2:
anatofuz
parents:
diff changeset
31 ;CHECK-NOT: s_waitcnt
anatofuz
parents:
diff changeset
32 ;CHECK: buffer_atomic_add v0, v1, s[0:3], 0 offen glc{{$}}
anatofuz
parents:
diff changeset
33 ;CHECK: s_waitcnt vmcnt(0)
anatofuz
parents:
diff changeset
34 ;CHECK: buffer_atomic_sub v0, v1, s[0:3], 0 offen glc slc
anatofuz
parents:
diff changeset
35 ;CHECK: s_waitcnt vmcnt(0)
anatofuz
parents:
diff changeset
36 ;CHECK: buffer_atomic_smin v0, v1, s[0:3], 0 offen glc{{$}}
anatofuz
parents:
diff changeset
37 ;CHECK: s_waitcnt vmcnt(0)
anatofuz
parents:
diff changeset
38 ;CHECK: buffer_atomic_umin v0, v1, s[0:3], 0 offen glc slc
anatofuz
parents:
diff changeset
39 ;CHECK: s_waitcnt vmcnt(0)
anatofuz
parents:
diff changeset
40 ;CHECK: buffer_atomic_smax v0, v1, s[0:3], 0 offen glc{{$}}
anatofuz
parents:
diff changeset
41 ;CHECK: s_waitcnt vmcnt(0)
anatofuz
parents:
diff changeset
42 ;CHECK: buffer_atomic_umax v0, v1, s[0:3], 0 offen glc slc
anatofuz
parents:
diff changeset
43 ;CHECK: s_waitcnt vmcnt(0)
anatofuz
parents:
diff changeset
44 ;CHECK: buffer_atomic_and v0, v1, s[0:3], 0 offen glc{{$}}
anatofuz
parents:
diff changeset
45 ;CHECK: s_waitcnt vmcnt(0)
anatofuz
parents:
diff changeset
46 ;CHECK: buffer_atomic_or v0, v1, s[0:3], 0 offen glc slc
anatofuz
parents:
diff changeset
47 ;CHECK: s_waitcnt vmcnt(0)
anatofuz
parents:
diff changeset
48 ;CHECK: buffer_atomic_xor v0, v1, s[0:3], 0 offen glc
anatofuz
parents:
diff changeset
49 ;CHECK: s_waitcnt vmcnt(0)
anatofuz
parents:
diff changeset
50 ;CHECK: buffer_atomic_inc v0, v1, s[0:3], 0 offen glc
anatofuz
parents:
diff changeset
51 ;CHECK: s_waitcnt vmcnt(0)
anatofuz
parents:
diff changeset
52 ;CHECK: buffer_atomic_dec v0, v1, s[0:3], 0 offen glc
anatofuz
parents:
diff changeset
53 define amdgpu_ps float @test2(<4 x i32> inreg %rsrc, i32 %data, i32 %voffset) {
anatofuz
parents:
diff changeset
54 main_body:
anatofuz
parents:
diff changeset
55 %t1 = call i32 @llvm.amdgcn.raw.buffer.atomic.add.i32(i32 %data, <4 x i32> %rsrc, i32 %voffset, i32 0, i32 0)
anatofuz
parents:
diff changeset
56 %t2 = call i32 @llvm.amdgcn.raw.buffer.atomic.sub.i32(i32 %t1, <4 x i32> %rsrc, i32 %voffset, i32 0, i32 2)
anatofuz
parents:
diff changeset
57 %t3 = call i32 @llvm.amdgcn.raw.buffer.atomic.smin.i32(i32 %t2, <4 x i32> %rsrc, i32 %voffset, i32 0, i32 0)
anatofuz
parents:
diff changeset
58 %t4 = call i32 @llvm.amdgcn.raw.buffer.atomic.umin.i32(i32 %t3, <4 x i32> %rsrc, i32 %voffset, i32 0, i32 2)
anatofuz
parents:
diff changeset
59 %t5 = call i32 @llvm.amdgcn.raw.buffer.atomic.smax.i32(i32 %t4, <4 x i32> %rsrc, i32 %voffset, i32 0, i32 0)
anatofuz
parents:
diff changeset
60 %t6 = call i32 @llvm.amdgcn.raw.buffer.atomic.umax.i32(i32 %t5, <4 x i32> %rsrc, i32 %voffset, i32 0, i32 2)
anatofuz
parents:
diff changeset
61 %t7 = call i32 @llvm.amdgcn.raw.buffer.atomic.and.i32(i32 %t6, <4 x i32> %rsrc, i32 %voffset, i32 0, i32 0)
anatofuz
parents:
diff changeset
62 %t8 = call i32 @llvm.amdgcn.raw.buffer.atomic.or.i32(i32 %t7, <4 x i32> %rsrc, i32 %voffset, i32 0, i32 2)
anatofuz
parents:
diff changeset
63 %t9 = call i32 @llvm.amdgcn.raw.buffer.atomic.xor.i32(i32 %t8, <4 x i32> %rsrc, i32 %voffset, i32 0, i32 0)
anatofuz
parents:
diff changeset
64 %t10 = call i32 @llvm.amdgcn.raw.buffer.atomic.inc.i32(i32 %t9, <4 x i32> %rsrc, i32 %voffset, i32 0, i32 0)
anatofuz
parents:
diff changeset
65 %t11 = call i32 @llvm.amdgcn.raw.buffer.atomic.dec.i32(i32 %t10, <4 x i32> %rsrc, i32 %voffset, i32 0, i32 0)
anatofuz
parents:
diff changeset
66 %out = bitcast i32 %t11 to float
anatofuz
parents:
diff changeset
67 ret float %out
anatofuz
parents:
diff changeset
68 }
anatofuz
parents:
diff changeset
69
anatofuz
parents:
diff changeset
70 ; Ideally, we would teach tablegen & friends that cmpswap only modifies the
anatofuz
parents:
diff changeset
71 ; first vgpr. Since we don't do that yet, the register allocator will have to
anatofuz
parents:
diff changeset
72 ; create copies which we don't bother to track here.
anatofuz
parents:
diff changeset
73 ;
anatofuz
parents:
diff changeset
74 ;CHECK-LABEL: {{^}}test3:
anatofuz
parents:
diff changeset
75 ;CHECK-NOT: s_waitcnt
anatofuz
parents:
diff changeset
76 ;CHECK: buffer_atomic_cmpswap {{v\[[0-9]+:[0-9]+\]}}, off, s[0:3], 0 glc
anatofuz
parents:
diff changeset
77 ;CHECK: s_waitcnt vmcnt(0)
anatofuz
parents:
diff changeset
78 ;CHECK: s_movk_i32 [[SOFS:s[0-9]+]], 0x1ffc
anatofuz
parents:
diff changeset
79 ;CHECK: buffer_atomic_cmpswap {{v\[[0-9]+:[0-9]+\]}}, v2, s[0:3], 0 offen glc
anatofuz
parents:
diff changeset
80 ;CHECK: s_waitcnt vmcnt(0)
anatofuz
parents:
diff changeset
81 ;CHECK: buffer_atomic_cmpswap {{v\[[0-9]+:[0-9]+\]}}, v2, s[0:3], 0 offen offset:44 glc
anatofuz
parents:
diff changeset
82 ;CHECK-DAG: s_waitcnt vmcnt(0)
anatofuz
parents:
diff changeset
83 ;CHECK: buffer_atomic_cmpswap {{v\[[0-9]+:[0-9]+\]}}, off, s[0:3], [[SOFS]] offset:4 glc
anatofuz
parents:
diff changeset
84 define amdgpu_ps float @test3(<4 x i32> inreg %rsrc, i32 %data, i32 %cmp, i32 %vindex, i32 %voffset) {
anatofuz
parents:
diff changeset
85 main_body:
anatofuz
parents:
diff changeset
86 %o1 = call i32 @llvm.amdgcn.raw.buffer.atomic.cmpswap.i32(i32 %data, i32 %cmp, <4 x i32> %rsrc, i32 0, i32 0, i32 0)
anatofuz
parents:
diff changeset
87 %o3 = call i32 @llvm.amdgcn.raw.buffer.atomic.cmpswap.i32(i32 %o1, i32 %cmp, <4 x i32> %rsrc, i32 %voffset, i32 0, i32 0)
anatofuz
parents:
diff changeset
88 %ofs.5 = add i32 %voffset, 44
anatofuz
parents:
diff changeset
89 %o5 = call i32 @llvm.amdgcn.raw.buffer.atomic.cmpswap.i32(i32 %o3, i32 %cmp, <4 x i32> %rsrc, i32 %ofs.5, i32 0, i32 0)
anatofuz
parents:
diff changeset
90 %o6 = call i32 @llvm.amdgcn.raw.buffer.atomic.cmpswap.i32(i32 %o5, i32 %cmp, <4 x i32> %rsrc, i32 4, i32 8188, i32 0)
anatofuz
parents:
diff changeset
91
anatofuz
parents:
diff changeset
92 ; Detecting the no-return variant doesn't work right now because of how the
anatofuz
parents:
diff changeset
93 ; intrinsic is replaced by an instruction that feeds into an EXTRACT_SUBREG.
anatofuz
parents:
diff changeset
94 ; Since there probably isn't a reasonable use-case of cmpswap that discards
anatofuz
parents:
diff changeset
95 ; the return value, that seems okay.
anatofuz
parents:
diff changeset
96 ;
anatofuz
parents:
diff changeset
97 ; %unused = call i32 @llvm.amdgcn.raw.buffer.atomic.cmpswap.i32(i32 %o6, i32 %cmp, <4 x i32> %rsrc, i32 0, i32 0, i32 0)
anatofuz
parents:
diff changeset
98 %out = bitcast i32 %o6 to float
anatofuz
parents:
diff changeset
99 ret float %out
anatofuz
parents:
diff changeset
100 }
anatofuz
parents:
diff changeset
101
anatofuz
parents:
diff changeset
102 ;CHECK-LABEL: {{^}}test4:
anatofuz
parents:
diff changeset
103 ;CHECK: buffer_atomic_add v0,
anatofuz
parents:
diff changeset
104 define amdgpu_ps float @test4() {
anatofuz
parents:
diff changeset
105 main_body:
anatofuz
parents:
diff changeset
106 %v = call i32 @llvm.amdgcn.raw.buffer.atomic.add.i32(i32 1, <4 x i32> undef, i32 4, i32 0, i32 0)
anatofuz
parents:
diff changeset
107 %v.float = bitcast i32 %v to float
anatofuz
parents:
diff changeset
108 ret float %v.float
anatofuz
parents:
diff changeset
109 }
anatofuz
parents:
diff changeset
110
anatofuz
parents:
diff changeset
111 declare i32 @llvm.amdgcn.raw.buffer.atomic.swap.i32(i32, <4 x i32>, i32, i32, i32) #0
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
112 declare float @llvm.amdgcn.raw.buffer.atomic.swap.f32(float, <4 x i32>, i32, i32, i32) #0
150
anatofuz
parents:
diff changeset
113 declare i32 @llvm.amdgcn.raw.buffer.atomic.add.i32(i32, <4 x i32>, i32, i32, i32) #0
anatofuz
parents:
diff changeset
114 declare i32 @llvm.amdgcn.raw.buffer.atomic.sub.i32(i32, <4 x i32>, i32, i32, i32) #0
anatofuz
parents:
diff changeset
115 declare i32 @llvm.amdgcn.raw.buffer.atomic.smin.i32(i32, <4 x i32>, i32, i32, i32) #0
anatofuz
parents:
diff changeset
116 declare i32 @llvm.amdgcn.raw.buffer.atomic.umin.i32(i32, <4 x i32>, i32, i32, i32) #0
anatofuz
parents:
diff changeset
117 declare i32 @llvm.amdgcn.raw.buffer.atomic.smax.i32(i32, <4 x i32>, i32, i32, i32) #0
anatofuz
parents:
diff changeset
118 declare i32 @llvm.amdgcn.raw.buffer.atomic.umax.i32(i32, <4 x i32>, i32, i32, i32) #0
anatofuz
parents:
diff changeset
119 declare i32 @llvm.amdgcn.raw.buffer.atomic.and.i32(i32, <4 x i32>, i32, i32, i32) #0
anatofuz
parents:
diff changeset
120 declare i32 @llvm.amdgcn.raw.buffer.atomic.or.i32(i32, <4 x i32>, i32, i32, i32) #0
anatofuz
parents:
diff changeset
121 declare i32 @llvm.amdgcn.raw.buffer.atomic.xor.i32(i32, <4 x i32>, i32, i32, i32) #0
anatofuz
parents:
diff changeset
122 declare i32 @llvm.amdgcn.raw.buffer.atomic.inc.i32(i32, <4 x i32>, i32, i32, i32) #0
anatofuz
parents:
diff changeset
123 declare i32 @llvm.amdgcn.raw.buffer.atomic.dec.i32(i32, <4 x i32>, i32, i32, i32) #0
anatofuz
parents:
diff changeset
124 declare i32 @llvm.amdgcn.raw.buffer.atomic.cmpswap.i32(i32, i32, <4 x i32>, i32, i32, i32) #0
anatofuz
parents:
diff changeset
125
anatofuz
parents:
diff changeset
126 attributes #0 = { nounwind }