Implement new way of expanding extloads.
[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
3 ; SI-LABEL: {{^}}unaligned_load_store_i32:
4 ; SI: ds_read_u8
5 ; SI: ds_read_u8
6 ; SI: ds_write_b32
7 ; SI: s_endpgm
8 define void @unaligned_load_store_i32(i32 addrspace(3)* %p, i32 addrspace(3)* %r) nounwind {
9   %v = load i32 addrspace(3)* %p, align 1
10   store i32 %v, i32 addrspace(3)* %r, align 1
11   ret void
12 }
13
14 ; SI-LABEL: {{^}}unaligned_load_store_v4i32:
15 ; SI: ds_read_u8
16 ; SI: ds_read_u8
17 ; SI: ds_read_u8
18 ; SI: ds_read_u8
19
20 ; SI: ds_read_u8
21 ; SI: ds_read_u8
22 ; SI: ds_read_u8
23 ; SI: ds_read_u8
24
25 ; SI: ds_read_u8
26 ; SI: ds_read_u8
27 ; SI: ds_read_u8
28 ; SI: ds_read_u8
29
30 ; SI: ds_read_u8
31 ; SI: ds_read_u8
32 ; SI: ds_read_u8
33 ; SI: ds_read_u8
34
35 ; SI: ds_write_b32
36 ; SI: ds_write_b32
37 ; SI: ds_write_b32
38 ; SI: ds_write_b32
39 ; SI: s_endpgm
40 define void @unaligned_load_store_v4i32(<4 x i32> addrspace(3)* %p, <4 x i32> addrspace(3)* %r) nounwind {
41   %v = load <4 x i32> addrspace(3)* %p, align 1
42   store <4 x i32> %v, <4 x i32> addrspace(3)* %r, align 1
43   ret void
44 }
45
46 ; SI-LABEL: {{^}}load_lds_i64_align_4:
47 ; SI: ds_read2_b32
48 ; SI: s_endpgm
49 define void @load_lds_i64_align_4(i64 addrspace(1)* nocapture %out, i64 addrspace(3)* %in) #0 {
50   %val = load i64 addrspace(3)* %in, align 4
51   store i64 %val, i64 addrspace(1)* %out, align 8
52   ret void
53 }
54
55 ; SI-LABEL: {{^}}load_lds_i64_align_4_with_offset
56 ; SI: ds_read2_b32 v[{{[0-9]+}}:{{[0-9]+}}], v{{[0-9]}} offset0:8 offset1:9
57 ; SI: s_endpgm
58 define void @load_lds_i64_align_4_with_offset(i64 addrspace(1)* nocapture %out, i64 addrspace(3)* %in) #0 {
59   %ptr = getelementptr i64 addrspace(3)* %in, i32 4
60   %val = load i64 addrspace(3)* %ptr, align 4
61   store i64 %val, i64 addrspace(1)* %out, align 8
62   ret void
63 }
64
65 ; SI-LABEL: {{^}}load_lds_i64_align_4_with_split_offset:
66 ; The tests for the case where the lo offset is 8-bits, but the hi offset is 9-bits
67 ; SI: ds_read2_b32 v[{{[0-9]+}}:{{[0-9]+}}], v{{[0-9]}} offset0:0 offset1:1
68 ; SI: s_endpgm
69 define void @load_lds_i64_align_4_with_split_offset(i64 addrspace(1)* nocapture %out, i64 addrspace(3)* %in) #0 {
70   %ptr = bitcast i64 addrspace(3)* %in to i32 addrspace(3)*
71   %ptr255 = getelementptr i32 addrspace(3)* %ptr, i32 255
72   %ptri64 = bitcast i32 addrspace(3)* %ptr255 to i64 addrspace(3)*
73   %val = load i64 addrspace(3)* %ptri64, align 4
74   store i64 %val, i64 addrspace(1)* %out, align 8
75   ret void
76 }
77
78 ; FIXME: Need to fix this case.
79 ; define void @load_lds_i64_align_1(i64 addrspace(1)* nocapture %out, i64 addrspace(3)* %in) #0 {
80 ;   %val = load i64 addrspace(3)* %in, align 1
81 ;   store i64 %val, i64 addrspace(1)* %out, align 8
82 ;   ret void
83 ; }
84
85 ; SI-LABEL: {{^}}store_lds_i64_align_4:
86 ; SI: ds_write2_b32
87 ; SI: s_endpgm
88 define void @store_lds_i64_align_4(i64 addrspace(3)* %out, i64 %val) #0 {
89   store i64 %val, i64 addrspace(3)* %out, align 4
90   ret void
91 }
92
93 ; SI-LABEL: {{^}}store_lds_i64_align_4_with_offset
94 ; SI: ds_write2_b32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} offset0:8 offset1:9
95 ; SI: s_endpgm
96 define void @store_lds_i64_align_4_with_offset(i64 addrspace(3)* %out) #0 {
97   %ptr = getelementptr i64 addrspace(3)* %out, i32 4
98   store i64 0, i64 addrspace(3)* %ptr, align 4
99   ret void
100 }
101
102 ; SI-LABEL: {{^}}store_lds_i64_align_4_with_split_offset:
103 ; The tests for the case where the lo offset is 8-bits, but the hi offset is 9-bits
104 ; SI: ds_write2_b32 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} offset0:0 offset1:1
105 ; SI: s_endpgm
106 define void @store_lds_i64_align_4_with_split_offset(i64 addrspace(3)* %out) #0 {
107   %ptr = bitcast i64 addrspace(3)* %out to i32 addrspace(3)*
108   %ptr255 = getelementptr i32 addrspace(3)* %ptr, i32 255
109   %ptri64 = bitcast i32 addrspace(3)* %ptr255 to i64 addrspace(3)*
110   store i64 0, i64 addrspace(3)* %out, align 4
111   ret void
112 }