blob: 78c5281ed73e163a07b9420b23462a2b5545b876 [file] [log] [blame]
Mark Searles2a19af62018-04-26 16:11:19 +00001;RUN: llc < %s -march=amdgcn -mcpu=verde -verify-machineinstrs | FileCheck -check-prefix=VERDE %s
Nicolai Haehnleb1427702016-03-10 18:43:50 +00002;RUN: llc < %s -march=amdgcn -mcpu=tonga -verify-machineinstrs | FileCheck %s
3
4;CHECK-LABEL: {{^}}buffer_store:
Marek Olsak5cec6412017-11-09 01:52:48 +00005;CHECK-NOT: s_waitcnt
Nikolay Haustov4f672a32016-04-29 09:02:30 +00006;CHECK: buffer_store_format_xyzw v[0:3], off, s[0:3], 0
7;CHECK: buffer_store_format_xyzw v[4:7], off, s[0:3], 0 glc
8;CHECK: buffer_store_format_xyzw v[8:11], off, s[0:3], 0 slc
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +00009define amdgpu_ps void @buffer_store(<4 x i32> inreg, <4 x float>, <4 x float>, <4 x float>) {
Nicolai Haehnleb1427702016-03-10 18:43:50 +000010main_body:
Nicolai Haehnle3003ba02016-03-18 16:24:20 +000011 call void @llvm.amdgcn.buffer.store.format.v4f32(<4 x float> %1, <4 x i32> %0, i32 0, i32 0, i1 0, i1 0)
12 call void @llvm.amdgcn.buffer.store.format.v4f32(<4 x float> %2, <4 x i32> %0, i32 0, i32 0, i1 1, i1 0)
13 call void @llvm.amdgcn.buffer.store.format.v4f32(<4 x float> %3, <4 x i32> %0, i32 0, i32 0, i1 0, i1 1)
Nicolai Haehnleb1427702016-03-10 18:43:50 +000014 ret void
15}
16
17;CHECK-LABEL: {{^}}buffer_store_immoffs:
Marek Olsak5cec6412017-11-09 01:52:48 +000018;CHECK-NOT: s_waitcnt
Nikolay Haustov4f672a32016-04-29 09:02:30 +000019;CHECK: buffer_store_format_xyzw v[0:3], off, s[0:3], 0 offset:42
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +000020define amdgpu_ps void @buffer_store_immoffs(<4 x i32> inreg, <4 x float>) {
Nicolai Haehnleb1427702016-03-10 18:43:50 +000021main_body:
Nicolai Haehnle3003ba02016-03-18 16:24:20 +000022 call void @llvm.amdgcn.buffer.store.format.v4f32(<4 x float> %1, <4 x i32> %0, i32 0, i32 42, i1 0, i1 0)
Nicolai Haehnleb1427702016-03-10 18:43:50 +000023 ret void
24}
25
26;CHECK-LABEL: {{^}}buffer_store_idx:
Marek Olsak5cec6412017-11-09 01:52:48 +000027;CHECK-NOT: s_waitcnt
Nicolai Haehnleb1427702016-03-10 18:43:50 +000028;CHECK: buffer_store_format_xyzw v[0:3], v4, s[0:3], 0 idxen
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +000029define amdgpu_ps void @buffer_store_idx(<4 x i32> inreg, <4 x float>, i32) {
Nicolai Haehnleb1427702016-03-10 18:43:50 +000030main_body:
Nicolai Haehnle3003ba02016-03-18 16:24:20 +000031 call void @llvm.amdgcn.buffer.store.format.v4f32(<4 x float> %1, <4 x i32> %0, i32 %2, i32 0, i1 0, i1 0)
Nicolai Haehnleb1427702016-03-10 18:43:50 +000032 ret void
33}
34
35;CHECK-LABEL: {{^}}buffer_store_ofs:
Marek Olsak5cec6412017-11-09 01:52:48 +000036;CHECK-NOT: s_waitcnt
Nicolai Haehnleb1427702016-03-10 18:43:50 +000037;CHECK: buffer_store_format_xyzw v[0:3], v4, s[0:3], 0 offen
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +000038define amdgpu_ps void @buffer_store_ofs(<4 x i32> inreg, <4 x float>, i32) {
Nicolai Haehnleb1427702016-03-10 18:43:50 +000039main_body:
Nicolai Haehnle3003ba02016-03-18 16:24:20 +000040 call void @llvm.amdgcn.buffer.store.format.v4f32(<4 x float> %1, <4 x i32> %0, i32 0, i32 %2, i1 0, i1 0)
Nicolai Haehnleb1427702016-03-10 18:43:50 +000041 ret void
42}
43
44;CHECK-LABEL: {{^}}buffer_store_both:
Marek Olsak5cec6412017-11-09 01:52:48 +000045;CHECK-NOT: s_waitcnt
Nicolai Haehnleb1427702016-03-10 18:43:50 +000046;CHECK: buffer_store_format_xyzw v[0:3], v[4:5], s[0:3], 0 idxen offen
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +000047define amdgpu_ps void @buffer_store_both(<4 x i32> inreg, <4 x float>, i32, i32) {
Nicolai Haehnleb1427702016-03-10 18:43:50 +000048main_body:
Nicolai Haehnle3003ba02016-03-18 16:24:20 +000049 call void @llvm.amdgcn.buffer.store.format.v4f32(<4 x float> %1, <4 x i32> %0, i32 %2, i32 %3, i1 0, i1 0)
Nicolai Haehnleb1427702016-03-10 18:43:50 +000050 ret void
51}
52
53;CHECK-LABEL: {{^}}buffer_store_both_reversed:
54;CHECK: v_mov_b32_e32 v6, v4
Marek Olsak5cec6412017-11-09 01:52:48 +000055;CHECK-NOT: s_waitcnt
Nicolai Haehnleb1427702016-03-10 18:43:50 +000056;CHECK: buffer_store_format_xyzw v[0:3], v[5:6], s[0:3], 0 idxen offen
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +000057define amdgpu_ps void @buffer_store_both_reversed(<4 x i32> inreg, <4 x float>, i32, i32) {
Nicolai Haehnleb1427702016-03-10 18:43:50 +000058main_body:
Nicolai Haehnle3003ba02016-03-18 16:24:20 +000059 call void @llvm.amdgcn.buffer.store.format.v4f32(<4 x float> %1, <4 x i32> %0, i32 %3, i32 %2, i1 0, i1 0)
Nicolai Haehnleb1427702016-03-10 18:43:50 +000060 ret void
61}
62
63; Ideally, the register allocator would avoid the wait here
64;
65;CHECK-LABEL: {{^}}buffer_store_wait:
Marek Olsak5cec6412017-11-09 01:52:48 +000066;CHECK-NOT: s_waitcnt
Nicolai Haehnleb1427702016-03-10 18:43:50 +000067;CHECK: buffer_store_format_xyzw v[0:3], v4, s[0:3], 0 idxen
Mark Searles2a19af62018-04-26 16:11:19 +000068;VERDE: s_waitcnt expcnt(0)
Nicolai Haehnleb1427702016-03-10 18:43:50 +000069;CHECK: buffer_load_format_xyzw v[0:3], v5, s[0:3], 0 idxen
70;CHECK: s_waitcnt vmcnt(0)
71;CHECK: buffer_store_format_xyzw v[0:3], v6, s[0:3], 0 idxen
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +000072define amdgpu_ps void @buffer_store_wait(<4 x i32> inreg, <4 x float>, i32, i32, i32) {
Nicolai Haehnleb1427702016-03-10 18:43:50 +000073main_body:
Nicolai Haehnle3003ba02016-03-18 16:24:20 +000074 call void @llvm.amdgcn.buffer.store.format.v4f32(<4 x float> %1, <4 x i32> %0, i32 %2, i32 0, i1 0, i1 0)
Nicolai Haehnle95e8ffd2016-03-18 16:24:40 +000075 %data = call <4 x float> @llvm.amdgcn.buffer.load.format.v4f32(<4 x i32> %0, i32 %3, i32 0, i1 0, i1 0)
Nicolai Haehnle3003ba02016-03-18 16:24:20 +000076 call void @llvm.amdgcn.buffer.store.format.v4f32(<4 x float> %data, <4 x i32> %0, i32 %4, i32 0, i1 0, i1 0)
Nicolai Haehnleb1427702016-03-10 18:43:50 +000077 ret void
78}
79
Nicolai Haehnledf77c9a2016-04-12 21:18:10 +000080;CHECK-LABEL: {{^}}buffer_store_x1:
Marek Olsak5cec6412017-11-09 01:52:48 +000081;CHECK-NOT: s_waitcnt
Nicolai Haehnledf77c9a2016-04-12 21:18:10 +000082;CHECK: buffer_store_format_x v0, v1, s[0:3], 0 idxen
83define amdgpu_ps void @buffer_store_x1(<4 x i32> inreg %rsrc, float %data, i32 %index) {
84main_body:
85 call void @llvm.amdgcn.buffer.store.format.f32(float %data, <4 x i32> %rsrc, i32 %index, i32 0, i1 0, i1 0)
86 ret void
87}
88
89;CHECK-LABEL: {{^}}buffer_store_x2:
Marek Olsak5cec6412017-11-09 01:52:48 +000090;CHECK-NOT: s_waitcnt
Nicolai Haehnledf77c9a2016-04-12 21:18:10 +000091;CHECK: buffer_store_format_xy v[0:1], v2, s[0:3], 0 idxen
92define amdgpu_ps void @buffer_store_x2(<4 x i32> inreg %rsrc, <2 x float> %data, i32 %index) {
93main_body:
94 call void @llvm.amdgcn.buffer.store.format.v2f32(<2 x float> %data, <4 x i32> %rsrc, i32 %index, i32 0, i1 0, i1 0)
95 ret void
96}
97
98declare void @llvm.amdgcn.buffer.store.format.f32(float, <4 x i32>, i32, i32, i1, i1) #0
99declare void @llvm.amdgcn.buffer.store.format.v2f32(<2 x float>, <4 x i32>, i32, i32, i1, i1) #0
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +0000100declare void @llvm.amdgcn.buffer.store.format.v4f32(<4 x float>, <4 x i32>, i32, i32, i1, i1) #0
101declare <4 x float> @llvm.amdgcn.buffer.load.format.v4f32(<4 x i32>, i32, i32, i1, i1) #1
Nicolai Haehnleb1427702016-03-10 18:43:50 +0000102
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +0000103attributes #0 = { nounwind }
104attributes #1 = { nounwind readonly }