blob: ed7cf520e201b52371dd5a4baed922ec4a808d4c [file] [log] [blame]
Tom Stellard49f8bfd2015-01-06 18:00:21 +00001; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs< %s | FileCheck -check-prefix=SI %s
Marek Olsak75170772015-01-27 17:27:15 +00002; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs< %s | FileCheck -check-prefix=SI %s
Matt Arsenault2ba54c32013-10-30 23:30:05 +00003
Tom Stellard79243d92014-10-01 17:15:17 +00004; SI-LABEL: {{^}}unaligned_load_store_i32:
Matt Arsenaultbd223422015-01-14 01:35:17 +00005; SI: ds_read_u8
6; SI: ds_read_u8
Tom Stellard326d6ec2014-11-05 14:50:53 +00007; SI: ds_write_b32
8; SI: s_endpgm
Matt Arsenault2ba54c32013-10-30 23:30:05 +00009define void @unaligned_load_store_i32(i32 addrspace(3)* %p, i32 addrspace(3)* %r) nounwind {
10 %v = load i32 addrspace(3)* %p, align 1
11 store i32 %v, i32 addrspace(3)* %r, align 1
12 ret void
13}
14
Tom Stellard79243d92014-10-01 17:15:17 +000015; SI-LABEL: {{^}}unaligned_load_store_v4i32:
Matt Arsenaultbd223422015-01-14 01:35:17 +000016; SI: ds_read_u8
17; SI: ds_read_u8
18; SI: ds_read_u8
19; SI: ds_read_u8
20
21; SI: ds_read_u8
22; SI: ds_read_u8
23; SI: ds_read_u8
24; SI: ds_read_u8
25
26; SI: ds_read_u8
27; SI: ds_read_u8
28; SI: ds_read_u8
29; SI: ds_read_u8
30
31; SI: ds_read_u8
32; SI: ds_read_u8
33; SI: ds_read_u8
34; SI: ds_read_u8
35
Tom Stellard326d6ec2014-11-05 14:50:53 +000036; SI: ds_write_b32
37; SI: ds_write_b32
38; SI: ds_write_b32
39; SI: ds_write_b32
40; SI: s_endpgm
Matt Arsenault2ba54c32013-10-30 23:30:05 +000041define void @unaligned_load_store_v4i32(<4 x i32> addrspace(3)* %p, <4 x i32> addrspace(3)* %r) nounwind {
42 %v = load <4 x i32> addrspace(3)* %p, align 1
43 store <4 x i32> %v, <4 x i32> addrspace(3)* %r, align 1
44 ret void
45}
Matt Arsenault6f2a5262014-07-27 17:46:40 +000046
Tom Stellard79243d92014-10-01 17:15:17 +000047; SI-LABEL: {{^}}load_lds_i64_align_4:
Tom Stellard326d6ec2014-11-05 14:50:53 +000048; SI: ds_read2_b32
49; SI: s_endpgm
Matt Arsenault6f2a5262014-07-27 17:46:40 +000050define void @load_lds_i64_align_4(i64 addrspace(1)* nocapture %out, i64 addrspace(3)* %in) #0 {
51 %val = load i64 addrspace(3)* %in, align 4
52 store i64 %val, i64 addrspace(1)* %out, align 8
53 ret void
54}
55
Matt Arsenault61cc9082014-10-10 22:16:07 +000056; SI-LABEL: {{^}}load_lds_i64_align_4_with_offset
Tom Stellard326d6ec2014-11-05 14:50:53 +000057; SI: ds_read2_b32 v[{{[0-9]+}}:{{[0-9]+}}], v{{[0-9]}} offset0:8 offset1:9
58; SI: s_endpgm
Tom Stellardf3fc5552014-08-22 18:49:35 +000059define void @load_lds_i64_align_4_with_offset(i64 addrspace(1)* nocapture %out, i64 addrspace(3)* %in) #0 {
60 %ptr = getelementptr i64 addrspace(3)* %in, i32 4
61 %val = load i64 addrspace(3)* %ptr, align 4
62 store i64 %val, i64 addrspace(1)* %out, align 8
63 ret void
64}
65
Tom Stellard79243d92014-10-01 17:15:17 +000066; SI-LABEL: {{^}}load_lds_i64_align_4_with_split_offset:
Tom Stellardf3fc5552014-08-22 18:49:35 +000067; The tests for the case where the lo offset is 8-bits, but the hi offset is 9-bits
Tom Stellard326d6ec2014-11-05 14:50:53 +000068; SI: ds_read2_b32 v[{{[0-9]+}}:{{[0-9]+}}], v{{[0-9]}} offset0:0 offset1:1
69; SI: s_endpgm
Tom Stellardf3fc5552014-08-22 18:49:35 +000070define void @load_lds_i64_align_4_with_split_offset(i64 addrspace(1)* nocapture %out, i64 addrspace(3)* %in) #0 {
71 %ptr = bitcast i64 addrspace(3)* %in to i32 addrspace(3)*
72 %ptr255 = getelementptr i32 addrspace(3)* %ptr, i32 255
73 %ptri64 = bitcast i32 addrspace(3)* %ptr255 to i64 addrspace(3)*
74 %val = load i64 addrspace(3)* %ptri64, align 4
75 store i64 %val, i64 addrspace(1)* %out, align 8
76 ret void
77}
78
Tom Stellard4cd6dcd2015-02-02 18:02:23 +000079; SI: {{^}}load_lds_i64_align_1
80; SI: ds_read_u8
81; SI: ds_read_u8
82; SI: ds_read_u8
83; SI: ds_read_u8
84; SI: ds_read_u8
85; SI: ds_read_u8
86; SI: ds_read_u8
87; SI: ds_read_u8
88; SI: s_endpgm
89define void @load_lds_i64_align_1(i64 addrspace(1)* nocapture %out, i64 addrspace(3)* %in) #0 {
90 %val = load i64 addrspace(3)* %in, align 1
91 store i64 %val, i64 addrspace(1)* %out, align 8
92 ret void
93}
Tom Stellardf3fc5552014-08-22 18:49:35 +000094
Tom Stellard79243d92014-10-01 17:15:17 +000095; SI-LABEL: {{^}}store_lds_i64_align_4:
Tom Stellard326d6ec2014-11-05 14:50:53 +000096; SI: ds_write2_b32
97; SI: s_endpgm
Tom Stellardf3fc5552014-08-22 18:49:35 +000098define void @store_lds_i64_align_4(i64 addrspace(3)* %out, i64 %val) #0 {
99 store i64 %val, i64 addrspace(3)* %out, align 4
100 ret void
101}
102
Matt Arsenault61cc9082014-10-10 22:16:07 +0000103; SI-LABEL: {{^}}store_lds_i64_align_4_with_offset
Tom Stellard326d6ec2014-11-05 14:50:53 +0000104; SI: ds_write2_b32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} offset0:8 offset1:9
105; SI: s_endpgm
Tom Stellardf3fc5552014-08-22 18:49:35 +0000106define void @store_lds_i64_align_4_with_offset(i64 addrspace(3)* %out) #0 {
107 %ptr = getelementptr i64 addrspace(3)* %out, i32 4
108 store i64 0, i64 addrspace(3)* %ptr, align 4
109 ret void
110}
111
Tom Stellard79243d92014-10-01 17:15:17 +0000112; SI-LABEL: {{^}}store_lds_i64_align_4_with_split_offset:
Tom Stellardf3fc5552014-08-22 18:49:35 +0000113; The tests for the case where the lo offset is 8-bits, but the hi offset is 9-bits
Tom Stellard326d6ec2014-11-05 14:50:53 +0000114; SI: ds_write2_b32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} offset0:0 offset1:1
115; SI: s_endpgm
Tom Stellardf3fc5552014-08-22 18:49:35 +0000116define void @store_lds_i64_align_4_with_split_offset(i64 addrspace(3)* %out) #0 {
117 %ptr = bitcast i64 addrspace(3)* %out to i32 addrspace(3)*
118 %ptr255 = getelementptr i32 addrspace(3)* %ptr, i32 255
119 %ptri64 = bitcast i32 addrspace(3)* %ptr255 to i64 addrspace(3)*
120 store i64 0, i64 addrspace(3)* %out, align 4
121 ret void
122}