R600/SI: Merge two test files
[oota-llvm.git] / test / CodeGen / R600 / unaligned-load-store.ll
1 ; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs< %s | FileCheck -check-prefix=SI %s
2 ; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs< %s | FileCheck -check-prefix=SI %s
3
4 ; SI-LABEL: {{^}}unaligned_load_store_i32:
5 ; SI: ds_read_u8
6 ; SI: ds_read_u8
7 ; SI: ds_write_b32
8 ; SI: s_endpgm
9 define 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
15 ; SI-LABEL: {{^}}unaligned_load_store_v4i32:
16 ; 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
36 ; SI: ds_write_b32
37 ; SI: ds_write_b32
38 ; SI: ds_write_b32
39 ; SI: ds_write_b32
40 ; SI: s_endpgm
41 define 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 }
46
47 ; SI-LABEL: {{^}}load_lds_i64_align_4:
48 ; SI: ds_read2_b32
49 ; SI: s_endpgm
50 define 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
56 ; SI-LABEL: {{^}}load_lds_i64_align_4_with_offset
57 ; SI: ds_read2_b32 v[{{[0-9]+}}:{{[0-9]+}}], v{{[0-9]}} offset0:8 offset1:9
58 ; SI: s_endpgm
59 define 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
66 ; SI-LABEL: {{^}}load_lds_i64_align_4_with_split_offset:
67 ; The tests for the case where the lo offset is 8-bits, but the hi offset is 9-bits
68 ; SI: ds_read2_b32 v[{{[0-9]+}}:{{[0-9]+}}], v{{[0-9]}} offset0:0 offset1:1
69 ; SI: s_endpgm
70 define 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
79 ; 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
89 define 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 }
94
95 ; SI-LABEL: {{^}}store_lds_i64_align_4:
96 ; SI: ds_write2_b32
97 ; SI: s_endpgm
98 define 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
103 ; SI-LABEL: {{^}}store_lds_i64_align_4_with_offset
104 ; SI: ds_write2_b32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} offset0:8 offset1:9
105 ; SI: s_endpgm
106 define 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
112 ; SI-LABEL: {{^}}store_lds_i64_align_4_with_split_offset:
113 ; The tests for the case where the lo offset is 8-bits, but the hi offset is 9-bits
114 ; SI: ds_write2_b32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} offset0:0 offset1:1
115 ; SI: s_endpgm
116 define 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 }