1 ; RUN: opt -mtriple=amdgcn-amd-amdhsa -mattr=+max-private-element-size-4,-unaligned-scratch-access -passes=load-store-vectorizer -S -o - %s | FileCheck -check-prefixes=ELT4,ELT4-ALIGNED,ALIGNED,ALL %s
2 ; RUN: opt -mtriple=amdgcn-amd-amdhsa -mattr=+max-private-element-size-8,-unaligned-scratch-access -passes=load-store-vectorizer -S -o - %s | FileCheck -check-prefixes=ELT8,ALIGNED,ALL %s
3 ; RUN: opt -mtriple=amdgcn-amd-amdhsa -mattr=+max-private-element-size-16,-unaligned-scratch-access -passes=load-store-vectorizer -S -o - %s | FileCheck -check-prefixes=ELT16,ALIGNED,ALL %s
4 ; RUN: opt -mtriple=amdgcn-amd-amdhsa -mattr=+max-private-element-size-4,+unaligned-scratch-access -passes=load-store-vectorizer -S -o - %s | FileCheck -check-prefixes=ELT4,ELT4-UNALIGNED,UNALIGNED,ALL %s
5 ; RUN: opt -mtriple=amdgcn-amd-amdhsa -mattr=+max-private-element-size-8,+unaligned-scratch-access -passes=load-store-vectorizer -S -o - %s | FileCheck -check-prefixes=ELT8,ELT8-UNALIGNED,UNALIGNED,ALL %s
6 ; RUN: opt -mtriple=amdgcn-amd-amdhsa -mattr=+max-private-element-size-16,+unaligned-scratch-access -passes=load-store-vectorizer -S -o - %s | FileCheck -check-prefixes=ELT16,ELT16-UNALIGNED,UNALIGNED,ALL %s
8 target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
10 ; ALL-LABEL: @merge_private_store_4_vector_elts_loads_v4i32
11 ; ELT4-ALIGNED: store i32
12 ; ELT4-ALIGNED: store i32
13 ; ELT4-ALIGNED: store i32
14 ; ELT4-ALIGNED: store i32
16 ; ELT8: store <2 x i32>
17 ; ELT8: store <2 x i32>
19 ; ELT16-UNALIGNED: store <4 x i32>
20 define amdgpu_kernel void @merge_private_store_4_vector_elts_loads_v4i32(ptr addrspace(5) %out) #0 {
21 %out.gep.1 = getelementptr i32, ptr addrspace(5) %out, i32 1
22 %out.gep.2 = getelementptr i32, ptr addrspace(5) %out, i32 2
23 %out.gep.3 = getelementptr i32, ptr addrspace(5) %out, i32 3
25 store i32 9, ptr addrspace(5) %out
26 store i32 1, ptr addrspace(5) %out.gep.1
27 store i32 23, ptr addrspace(5) %out.gep.2
28 store i32 19, ptr addrspace(5) %out.gep.3
32 ; ALL-LABEL: @merge_private_store_4_vector_elts_loads_v4i32_align1(
33 ; ALIGNED: store i32 9, ptr addrspace(5) %out, align 1
34 ; ALIGNED: store i32 1, ptr addrspace(5) %out.gep.1, align 1
35 ; ALIGNED: store i32 23, ptr addrspace(5) %out.gep.2, align 1
36 ; ALIGNED: store i32 19, ptr addrspace(5) %out.gep.3, align 1
38 ; ELT16-UNALIGNED: store <4 x i32> <i32 9, i32 1, i32 23, i32 19>, ptr addrspace(5) %out, align 1
40 ; ELT8-UNALIGNED: store <2 x i32> <i32 9, i32 1>, ptr addrspace(5) %out, align 1
41 ; ELT8-UNALIGNED: store <2 x i32> <i32 23, i32 19>, ptr addrspace(5) %out.gep.2, align 1
43 ; ELT4-UNALIGNED: store i32
44 ; ELT4-UNALIGNED: store i32
45 ; ELT4-UNALIGNED: store i32
46 ; ELT4-UNALIGNED: store i32
47 define amdgpu_kernel void @merge_private_store_4_vector_elts_loads_v4i32_align1(ptr addrspace(5) %out) #0 {
48 %out.gep.1 = getelementptr i32, ptr addrspace(5) %out, i32 1
49 %out.gep.2 = getelementptr i32, ptr addrspace(5) %out, i32 2
50 %out.gep.3 = getelementptr i32, ptr addrspace(5) %out, i32 3
52 store i32 9, ptr addrspace(5) %out, align 1
53 store i32 1, ptr addrspace(5) %out.gep.1, align 1
54 store i32 23, ptr addrspace(5) %out.gep.2, align 1
55 store i32 19, ptr addrspace(5) %out.gep.3, align 1
59 ; ALL-LABEL: @merge_private_store_4_vector_elts_loads_v4i32_align2(
64 ; ELT4-UNALIGNED: store i32
65 ; ELT4-UNALIGNED: store i32
66 ; ELT4-UNALIGNED: store i32
67 ; ELT4-UNALIGNED: store i32
68 ; ELT8-UNALIGNED: store <2 x i32>
69 ; ELT8-UNALIGNED: store <2 x i32>
70 ; ELT16-UNALIGNED: store <4 x i32>
71 define amdgpu_kernel void @merge_private_store_4_vector_elts_loads_v4i32_align2(ptr addrspace(5) %out) #0 {
72 %out.gep.1 = getelementptr i32, ptr addrspace(5) %out, i32 1
73 %out.gep.2 = getelementptr i32, ptr addrspace(5) %out, i32 2
74 %out.gep.3 = getelementptr i32, ptr addrspace(5) %out, i32 3
76 store i32 9, ptr addrspace(5) %out, align 2
77 store i32 1, ptr addrspace(5) %out.gep.1, align 2
78 store i32 23, ptr addrspace(5) %out.gep.2, align 2
79 store i32 19, ptr addrspace(5) %out.gep.3, align 2
83 ; ALL-LABEL: @merge_private_store_4_vector_elts_loads_v4i8(
85 define amdgpu_kernel void @merge_private_store_4_vector_elts_loads_v4i8(ptr addrspace(5) %out) #0 {
86 %out.gep.1 = getelementptr i8, ptr addrspace(5) %out, i32 1
87 %out.gep.2 = getelementptr i8, ptr addrspace(5) %out, i32 2
88 %out.gep.3 = getelementptr i8, ptr addrspace(5) %out, i32 3
90 store i8 9, ptr addrspace(5) %out, align 4
91 store i8 1, ptr addrspace(5) %out.gep.1
92 store i8 23, ptr addrspace(5) %out.gep.2
93 store i8 19, ptr addrspace(5) %out.gep.3
97 ; ALL-LABEL: @merge_private_store_4_vector_elts_loads_v4i8_align1(
103 ; UNALIGNED: store <4 x i8> <i8 9, i8 1, i8 23, i8 19>, ptr addrspace(5) %out, align 1
104 define amdgpu_kernel void @merge_private_store_4_vector_elts_loads_v4i8_align1(ptr addrspace(5) %out) #0 {
105 %out.gep.1 = getelementptr i8, ptr addrspace(5) %out, i32 1
106 %out.gep.2 = getelementptr i8, ptr addrspace(5) %out, i32 2
107 %out.gep.3 = getelementptr i8, ptr addrspace(5) %out, i32 3
109 store i8 9, ptr addrspace(5) %out, align 1
110 store i8 1, ptr addrspace(5) %out.gep.1, align 1
111 store i8 23, ptr addrspace(5) %out.gep.2, align 1
112 store i8 19, ptr addrspace(5) %out.gep.3, align 1
116 ; ALL-LABEL: @merge_private_store_4_vector_elts_loads_v2i16(
117 ; ALL: store <2 x i16>
118 define amdgpu_kernel void @merge_private_store_4_vector_elts_loads_v2i16(ptr addrspace(5) %out) #0 {
119 %out.gep.1 = getelementptr i16, ptr addrspace(5) %out, i32 1
121 store i16 9, ptr addrspace(5) %out, align 4
122 store i16 12, ptr addrspace(5) %out.gep.1
126 ; ALL-LABEL: @merge_private_store_4_vector_elts_loads_v2i16_align2(
129 ; UNALIGNED: store <2 x i16>
130 define amdgpu_kernel void @merge_private_store_4_vector_elts_loads_v2i16_align2(ptr addrspace(5) %out) #0 {
131 %out.gep.1 = getelementptr i16, ptr addrspace(5) %out, i32 1
133 store i16 9, ptr addrspace(5) %out, align 2
134 store i16 12, ptr addrspace(5) %out.gep.1, align 2
138 ; ALL-LABEL: @merge_private_store_4_vector_elts_loads_v2i16_align1(
142 ; UNALIGNED: store <2 x i16> <i16 9, i16 12>, ptr addrspace(5) %out, align 1
143 define amdgpu_kernel void @merge_private_store_4_vector_elts_loads_v2i16_align1(ptr addrspace(5) %out) #0 {
144 %out.gep.1 = getelementptr i16, ptr addrspace(5) %out, i32 1
146 store i16 9, ptr addrspace(5) %out, align 1
147 store i16 12, ptr addrspace(5) %out.gep.1, align 1
151 ; ALL-LABEL: @merge_private_store_4_vector_elts_loads_v2i16_align8(
152 ; ALL: store <2 x i16> <i16 9, i16 12>, ptr addrspace(5) %out, align 8
153 define amdgpu_kernel void @merge_private_store_4_vector_elts_loads_v2i16_align8(ptr addrspace(5) %out) #0 {
154 %out.gep.1 = getelementptr i16, ptr addrspace(5) %out, i32 1
156 store i16 9, ptr addrspace(5) %out, align 8
157 store i16 12, ptr addrspace(5) %out.gep.1, align 2
161 ; ALL-LABEL: @merge_private_store_3_vector_elts_loads_v4i32
166 ; ELT8: store <2 x i32>
169 ; ELT16: store <3 x i32>
170 define amdgpu_kernel void @merge_private_store_3_vector_elts_loads_v4i32(ptr addrspace(5) %out) #0 {
171 %out.gep.1 = getelementptr i32, ptr addrspace(5) %out, i32 1
172 %out.gep.2 = getelementptr i32, ptr addrspace(5) %out, i32 2
174 store i32 9, ptr addrspace(5) %out
175 store i32 1, ptr addrspace(5) %out.gep.1
176 store i32 23, ptr addrspace(5) %out.gep.2
180 ; ALL-LABEL: @merge_private_store_3_vector_elts_loads_v4i32_align1(
185 ; ELT4-UNALIGNED: store i32
186 ; ELT4-UNALIGNED: store i32
187 ; ELT4-UNALIGNED: store i32
189 ; ELT8-UNALIGNED: store <2 x i32>
190 ; ELT8-UNALIGNED: store i32
192 ; ELT16-UNALIGNED: store <3 x i32>
193 define amdgpu_kernel void @merge_private_store_3_vector_elts_loads_v4i32_align1(ptr addrspace(5) %out) #0 {
194 %out.gep.1 = getelementptr i32, ptr addrspace(5) %out, i32 1
195 %out.gep.2 = getelementptr i32, ptr addrspace(5) %out, i32 2
197 store i32 9, ptr addrspace(5) %out, align 1
198 store i32 1, ptr addrspace(5) %out.gep.1, align 1
199 store i32 23, ptr addrspace(5) %out.gep.2, align 1
203 ; ALL-LABEL: @merge_private_store_3_vector_elts_loads_v4i8_align1(
208 ; UNALIGNED: store <3 x i8>
209 define amdgpu_kernel void @merge_private_store_3_vector_elts_loads_v4i8_align1(ptr addrspace(5) %out) #0 {
210 %out.gep.1 = getelementptr i8, ptr addrspace(5) %out, i8 1
211 %out.gep.2 = getelementptr i8, ptr addrspace(5) %out, i8 2
213 store i8 9, ptr addrspace(5) %out, align 1
214 store i8 1, ptr addrspace(5) %out.gep.1, align 1
215 store i8 23, ptr addrspace(5) %out.gep.2, align 1
219 attributes #0 = { nounwind }