blob: c6222f426b3d2fa131224d2bbdda23e439389fa7 [file] [log] [blame]
Nicolai Haehnleb1427702016-03-10 18:43:50 +00001;RUN: llc < %s -march=amdgcn -mcpu=verde -verify-machineinstrs | FileCheck %s
2;RUN: llc < %s -march=amdgcn -mcpu=tonga -verify-machineinstrs | FileCheck %s
3
4;CHECK-LABEL: {{^}}buffer_load:
Nicolai Haehnle3003ba02016-03-18 16:24:20 +00005;CHECK: buffer_load_format_xyzw v[0:3], s[0:3], 0
6;CHECK: buffer_load_format_xyzw v[4:7], s[0:3], 0 glc
7;CHECK: buffer_load_format_xyzw v[8:11], s[0:3], 0 slc
Nicolai Haehnleb1427702016-03-10 18:43:50 +00008;CHECK: s_waitcnt
Nicolai Haehnle3003ba02016-03-18 16:24:20 +00009define {<4 x float>, <4 x float>, <4 x float>} @buffer_load(<4 x i32> inreg) #0 {
Nicolai Haehnleb1427702016-03-10 18:43:50 +000010main_body:
Nicolai Haehnle3003ba02016-03-18 16:24:20 +000011 %data = call <4 x float> @llvm.amdgcn.buffer.load.format(<4 x i32> %0, i32 0, i32 0, i1 0, i1 0)
12 %data_glc = call <4 x float> @llvm.amdgcn.buffer.load.format(<4 x i32> %0, i32 0, i32 0, i1 1, i1 0)
13 %data_slc = call <4 x float> @llvm.amdgcn.buffer.load.format(<4 x i32> %0, i32 0, i32 0, i1 0, i1 1)
Nicolai Haehnleb1427702016-03-10 18:43:50 +000014 %r0 = insertvalue {<4 x float>, <4 x float>, <4 x float>} undef, <4 x float> %data, 0
15 %r1 = insertvalue {<4 x float>, <4 x float>, <4 x float>} %r0, <4 x float> %data_glc, 1
16 %r2 = insertvalue {<4 x float>, <4 x float>, <4 x float>} %r1, <4 x float> %data_slc, 2
17 ret {<4 x float>, <4 x float>, <4 x float>} %r2
18}
19
20;CHECK-LABEL: {{^}}buffer_load_immoffs:
Nicolai Haehnle3003ba02016-03-18 16:24:20 +000021;CHECK: buffer_load_format_xyzw v[0:3], s[0:3], 0 offset:42
Nicolai Haehnleb1427702016-03-10 18:43:50 +000022;CHECK: s_waitcnt
Nicolai Haehnle3003ba02016-03-18 16:24:20 +000023define <4 x float> @buffer_load_immoffs(<4 x i32> inreg) #0 {
Nicolai Haehnleb1427702016-03-10 18:43:50 +000024main_body:
Nicolai Haehnle3003ba02016-03-18 16:24:20 +000025 %data = call <4 x float> @llvm.amdgcn.buffer.load.format(<4 x i32> %0, i32 0, i32 42, i1 0, i1 0)
26 ret <4 x float> %data
27}
28
29;CHECK-LABEL: {{^}}buffer_load_immoffs_large:
30;CHECK-DAG: buffer_load_format_xyzw {{v\[[0-9]+:[0-9]+\]}}, s[0:3], 61 offset:4095
31;CHECK-DAG: s_movk_i32 [[OFS1:s[0-9]+]], 0x7fff
32;CHECK: buffer_load_format_xyzw {{v\[[0-9]+:[0-9]+\]}}, s[0:3], [[OFS1]] offset:4093
33;CHECK: s_mov_b32 [[OFS2:s[0-9]+]], 0x8fff
34;CHECK: buffer_load_format_xyzw {{v\[[0-9]+:[0-9]+\]}}, s[0:3], [[OFS2]] offset:1
35;CHECK: s_waitcnt
36define <4 x float> @buffer_load_immoffs_large(<4 x i32> inreg) #0 {
37main_body:
38 %d.0 = call <4 x float> @llvm.amdgcn.buffer.load.format(<4 x i32> %0, i32 0, i32 4156, i1 0, i1 0)
39 %d.1 = call <4 x float> @llvm.amdgcn.buffer.load.format(<4 x i32> %0, i32 0, i32 36860, i1 0, i1 0)
40 %d.2 = call <4 x float> @llvm.amdgcn.buffer.load.format(<4 x i32> %0, i32 0, i32 36864, i1 0, i1 0)
41 %d.3 = fadd <4 x float> %d.0, %d.1
42 %data = fadd <4 x float> %d.2, %d.3
43 ret <4 x float> %data
44}
45
46;CHECK-LABEL: {{^}}buffer_load_immoffs_reuse:
47;CHECK: s_movk_i32 [[OFS:s[0-9]+]], 0xfff
48;CHECK: buffer_load_format_xyzw {{v\[[0-9]+:[0-9]+\]}}, s[0:3], [[OFS]] offset:65
49;CHECK-NOT: s_mov
50;CHECK: buffer_load_format_xyzw {{v\[[0-9]+:[0-9]+\]}}, s[0:3], [[OFS]] offset:81
51;CHECK: s_waitcnt
52define <4 x float> @buffer_load_immoffs_reuse(<4 x i32> inreg) #0 {
53main_body:
54 %d.0 = call <4 x float> @llvm.amdgcn.buffer.load.format(<4 x i32> %0, i32 0, i32 4160, i1 0, i1 0)
55 %d.1 = call <4 x float> @llvm.amdgcn.buffer.load.format(<4 x i32> %0, i32 0, i32 4176, i1 0, i1 0)
56 %data = fadd <4 x float> %d.0, %d.1
Nicolai Haehnleb1427702016-03-10 18:43:50 +000057 ret <4 x float> %data
58}
59
60;CHECK-LABEL: {{^}}buffer_load_idx:
61;CHECK: buffer_load_format_xyzw v[0:3], v0, s[0:3], 0 idxen
62;CHECK: s_waitcnt
63define <4 x float> @buffer_load_idx(<4 x i32> inreg, i32) #0 {
64main_body:
Nicolai Haehnle3003ba02016-03-18 16:24:20 +000065 %data = call <4 x float> @llvm.amdgcn.buffer.load.format(<4 x i32> %0, i32 %1, i32 0, i1 0, i1 0)
Nicolai Haehnleb1427702016-03-10 18:43:50 +000066 ret <4 x float> %data
67}
68
69;CHECK-LABEL: {{^}}buffer_load_ofs:
70;CHECK: buffer_load_format_xyzw v[0:3], v0, s[0:3], 0 offen
71;CHECK: s_waitcnt
72define <4 x float> @buffer_load_ofs(<4 x i32> inreg, i32) #0 {
73main_body:
Nicolai Haehnle3003ba02016-03-18 16:24:20 +000074 %data = call <4 x float> @llvm.amdgcn.buffer.load.format(<4 x i32> %0, i32 0, i32 %1, i1 0, i1 0)
75 ret <4 x float> %data
76}
77
78;CHECK-LABEL: {{^}}buffer_load_ofs_imm:
79;CHECK: buffer_load_format_xyzw v[0:3], v0, s[0:3], 0 offen offset:58
80;CHECK: s_waitcnt
81define <4 x float> @buffer_load_ofs_imm(<4 x i32> inreg, i32) #0 {
82main_body:
83 %ofs = add i32 %1, 58
84 %data = call <4 x float> @llvm.amdgcn.buffer.load.format(<4 x i32> %0, i32 0, i32 %ofs, i1 0, i1 0)
Nicolai Haehnleb1427702016-03-10 18:43:50 +000085 ret <4 x float> %data
86}
87
88;CHECK-LABEL: {{^}}buffer_load_both:
89;CHECK: buffer_load_format_xyzw v[0:3], v[0:1], s[0:3], 0 idxen offen
90;CHECK: s_waitcnt
91define <4 x float> @buffer_load_both(<4 x i32> inreg, i32, i32) #0 {
92main_body:
Nicolai Haehnle3003ba02016-03-18 16:24:20 +000093 %data = call <4 x float> @llvm.amdgcn.buffer.load.format(<4 x i32> %0, i32 %1, i32 %2, i1 0, i1 0)
Nicolai Haehnleb1427702016-03-10 18:43:50 +000094 ret <4 x float> %data
95}
96
97;CHECK-LABEL: {{^}}buffer_load_both_reversed:
98;CHECK: v_mov_b32_e32 v2, v0
99;CHECK: buffer_load_format_xyzw v[0:3], v[1:2], s[0:3], 0 idxen offen
100;CHECK: s_waitcnt
101define <4 x float> @buffer_load_both_reversed(<4 x i32> inreg, i32, i32) #0 {
102main_body:
Nicolai Haehnle3003ba02016-03-18 16:24:20 +0000103 %data = call <4 x float> @llvm.amdgcn.buffer.load.format(<4 x i32> %0, i32 %2, i32 %1, i1 0, i1 0)
Nicolai Haehnleb1427702016-03-10 18:43:50 +0000104 ret <4 x float> %data
105}
106
Nicolai Haehnle3003ba02016-03-18 16:24:20 +0000107declare <4 x float> @llvm.amdgcn.buffer.load.format(<4 x i32>, i32, i32, i1, i1) #1
Nicolai Haehnleb1427702016-03-10 18:43:50 +0000108
109attributes #0 = { "ShaderType"="0" }
110attributes #1 = { nounwind readonly }