1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+d,+v -verify-machineinstrs < %s | FileCheck --check-prefixes=CHECK,RV32 %s
3 ; RUN: llc -mtriple=riscv64 -mattr=+d,+v -verify-machineinstrs < %s | FileCheck --check-prefixes=CHECK,RV64 %s
5 define void @combine_zero_stores_2xi8(ptr %p) {
6 ; CHECK-LABEL: combine_zero_stores_2xi8:
8 ; CHECK-NEXT: sh zero, 0(a0)
10 store i8 zeroinitializer, ptr %p, align 2
11 %gep = getelementptr i8, ptr %p, i64 1
12 store i8 zeroinitializer, ptr %gep
16 define void @combine_zero_stores_4xi8(ptr %p) {
17 ; CHECK-LABEL: combine_zero_stores_4xi8:
19 ; CHECK-NEXT: sw zero, 0(a0)
21 store i8 zeroinitializer, ptr %p, align 4
22 %gep1 = getelementptr i8, ptr %p, i64 1
23 store i8 zeroinitializer, ptr %gep1
24 %gep2 = getelementptr i8, ptr %p, i64 2
25 store i8 zeroinitializer, ptr %gep2
26 %gep3 = getelementptr i8, ptr %p, i64 3
27 store i8 zeroinitializer, ptr %gep3
31 define void @combine_zero_stores_8xi8(ptr %p) {
32 ; RV32-LABEL: combine_zero_stores_8xi8:
34 ; RV32-NEXT: sw zero, 0(a0)
35 ; RV32-NEXT: sw zero, 4(a0)
38 ; RV64-LABEL: combine_zero_stores_8xi8:
40 ; RV64-NEXT: sd zero, 0(a0)
42 store i8 zeroinitializer, ptr %p, align 8
43 %gep1 = getelementptr i8, ptr %p, i64 1
44 store i8 zeroinitializer, ptr %gep1
45 %gep2 = getelementptr i8, ptr %p, i64 2
46 store i8 zeroinitializer, ptr %gep2
47 %gep3 = getelementptr i8, ptr %p, i64 3
48 store i8 zeroinitializer, ptr %gep3
49 %gep4 = getelementptr i8, ptr %p, i64 4
50 store i8 zeroinitializer, ptr %gep4, align 8
51 %gep5 = getelementptr i8, ptr %p, i64 5
52 store i8 zeroinitializer, ptr %gep5
53 %gep6 = getelementptr i8, ptr %p, i64 6
54 store i8 zeroinitializer, ptr %gep6
55 %gep7 = getelementptr i8, ptr %p, i64 7
56 store i8 zeroinitializer, ptr %gep7
60 define void @combine_zero_stores_2xi16(ptr %p) {
61 ; CHECK-LABEL: combine_zero_stores_2xi16:
63 ; CHECK-NEXT: sw zero, 0(a0)
65 store i16 zeroinitializer, ptr %p, align 4
66 %gep = getelementptr i8, ptr %p, i64 2
67 store i16 zeroinitializer, ptr %gep
71 define void @combine_zero_stores_4xi16(ptr %p) {
72 ; RV32-LABEL: combine_zero_stores_4xi16:
74 ; RV32-NEXT: sw zero, 0(a0)
75 ; RV32-NEXT: sw zero, 4(a0)
78 ; RV64-LABEL: combine_zero_stores_4xi16:
80 ; RV64-NEXT: sd zero, 0(a0)
82 store i16 zeroinitializer, ptr %p, align 8
83 %gep1 = getelementptr i16, ptr %p, i64 1
84 store i16 zeroinitializer, ptr %gep1
85 %gep2 = getelementptr i16, ptr %p, i64 2
86 store i16 zeroinitializer, ptr %gep2, align 4
87 %gep3 = getelementptr i16, ptr %p, i64 3
88 store i16 zeroinitializer, ptr %gep3
92 define void @combine_zero_stores_8xi16(ptr %p) {
93 ; RV32-LABEL: combine_zero_stores_8xi16:
95 ; RV32-NEXT: sw zero, 0(a0)
96 ; RV32-NEXT: sh zero, 4(a0)
97 ; RV32-NEXT: sh zero, 6(a0)
98 ; RV32-NEXT: sw zero, 8(a0)
99 ; RV32-NEXT: sh zero, 12(a0)
100 ; RV32-NEXT: sh zero, 14(a0)
103 ; RV64-LABEL: combine_zero_stores_8xi16:
105 ; RV64-NEXT: sd zero, 0(a0)
106 ; RV64-NEXT: sd zero, 8(a0)
108 store i16 zeroinitializer, ptr %p, align 16
109 %gep1 = getelementptr i16, ptr %p, i64 1
110 store i16 zeroinitializer, ptr %gep1
111 %gep2 = getelementptr i16, ptr %p, i64 2
112 store i16 zeroinitializer, ptr %gep2
113 %gep3 = getelementptr i16, ptr %p, i64 3
114 store i16 zeroinitializer, ptr %gep3
115 %gep4 = getelementptr i16, ptr %p, i64 4
116 store i16 zeroinitializer, ptr %gep4, align 8
117 %gep5 = getelementptr i16, ptr %p, i64 5
118 store i16 zeroinitializer, ptr %gep5
119 %gep6 = getelementptr i16, ptr %p, i64 6
120 store i16 zeroinitializer, ptr %gep6
121 %gep7 = getelementptr i16, ptr %p, i64 7
122 store i16 zeroinitializer, ptr %gep7
126 define void @combine_zero_stores_2xi32(ptr %p) {
127 ; RV32-LABEL: combine_zero_stores_2xi32:
129 ; RV32-NEXT: sw zero, 0(a0)
130 ; RV32-NEXT: sw zero, 4(a0)
133 ; RV64-LABEL: combine_zero_stores_2xi32:
135 ; RV64-NEXT: sd zero, 0(a0)
137 store i32 zeroinitializer, ptr %p, align 8
138 %gep = getelementptr i8, ptr %p, i64 4
139 store i32 zeroinitializer, ptr %gep
143 define void @combine_zero_stores_4xi32(ptr %p) {
144 ; RV32-LABEL: combine_zero_stores_4xi32:
146 ; RV32-NEXT: vsetivli zero, 4, e32, m1, ta, ma
147 ; RV32-NEXT: vmv.v.i v8, 0
148 ; RV32-NEXT: vse32.v v8, (a0)
151 ; RV64-LABEL: combine_zero_stores_4xi32:
153 ; RV64-NEXT: sd zero, 0(a0)
154 ; RV64-NEXT: sd zero, 8(a0)
156 store i32 zeroinitializer, ptr %p, align 16
157 %gep1 = getelementptr i32, ptr %p, i64 1
158 store i32 zeroinitializer, ptr %gep1
159 %gep2 = getelementptr i32, ptr %p, i64 2
160 store i32 zeroinitializer, ptr %gep2, align 8
161 %gep3 = getelementptr i32, ptr %p, i64 3
162 store i32 zeroinitializer, ptr %gep3
166 define void @combine_zero_stores_8xi32(ptr %p) {
167 ; RV32-LABEL: combine_zero_stores_8xi32:
169 ; RV32-NEXT: vsetivli zero, 8, e32, m2, ta, ma
170 ; RV32-NEXT: vmv.v.i v8, 0
171 ; RV32-NEXT: vse32.v v8, (a0)
174 ; RV64-LABEL: combine_zero_stores_8xi32:
176 ; RV64-NEXT: vsetivli zero, 4, e64, m2, ta, ma
177 ; RV64-NEXT: vmv.v.i v8, 0
178 ; RV64-NEXT: vse64.v v8, (a0)
180 store i32 zeroinitializer, ptr %p, align 32
181 %gep1 = getelementptr i32, ptr %p, i64 1
182 store i32 zeroinitializer, ptr %gep1
183 %gep2 = getelementptr i32, ptr %p, i64 2
184 store i32 zeroinitializer, ptr %gep2, align 8
185 %gep3 = getelementptr i32, ptr %p, i64 3
186 store i32 zeroinitializer, ptr %gep3
187 %gep4 = getelementptr i32, ptr %p, i64 4
188 store i32 zeroinitializer, ptr %gep4, align 8
189 %gep5 = getelementptr i32, ptr %p, i64 5
190 store i32 zeroinitializer, ptr %gep5
191 %gep6 = getelementptr i32, ptr %p, i64 6
192 store i32 zeroinitializer, ptr %gep6, align 8
193 %gep7 = getelementptr i32, ptr %p, i64 7
194 store i32 zeroinitializer, ptr %gep7
198 define void @combine_zero_stores_2xi32_unaligned(ptr %p) {
199 ; CHECK-LABEL: combine_zero_stores_2xi32_unaligned:
201 ; CHECK-NEXT: sw zero, 0(a0)
202 ; CHECK-NEXT: sw zero, 4(a0)
204 store i32 zeroinitializer, ptr %p
205 %gep = getelementptr i8, ptr %p, i64 4
206 store i32 zeroinitializer, ptr %gep
210 define void @combine_zero_stores_2xi64(ptr %p) {
211 ; RV32-LABEL: combine_zero_stores_2xi64:
213 ; RV32-NEXT: sw zero, 4(a0)
214 ; RV32-NEXT: sw zero, 0(a0)
215 ; RV32-NEXT: sw zero, 12(a0)
216 ; RV32-NEXT: sw zero, 8(a0)
219 ; RV64-LABEL: combine_zero_stores_2xi64:
221 ; RV64-NEXT: sd zero, 0(a0)
222 ; RV64-NEXT: sd zero, 8(a0)
224 store i64 zeroinitializer, ptr %p
225 %gep = getelementptr i8, ptr %p, i64 8
226 store i64 zeroinitializer, ptr %gep
230 define void @combine_fp_zero_stores_crash(ptr %ptr) {
231 ; CHECK-LABEL: combine_fp_zero_stores_crash:
233 ; CHECK-NEXT: sw zero, 4(a0)
234 ; CHECK-NEXT: sw zero, 8(a0)
236 %addr1 = getelementptr float, ptr %ptr, i64 1
237 %addr2 = getelementptr float, ptr %ptr, i64 2
238 store float 0.000000e+00, ptr %addr1, align 4
239 store float 0.000000e+00, ptr %addr2, align 4
243 define void @combine_allones_stores_2xi8(ptr %p) {
244 ; CHECK-LABEL: combine_allones_stores_2xi8:
246 ; CHECK-NEXT: li a1, -1
247 ; CHECK-NEXT: sh a1, 0(a0)
249 store i8 -1, ptr %p, align 4
250 %gep = getelementptr i8, ptr %p, i64 1
251 store i8 -1, ptr %gep
255 define void @combine_allones_stores_2xi16(ptr %p) {
256 ; CHECK-LABEL: combine_allones_stores_2xi16:
258 ; CHECK-NEXT: li a1, -1
259 ; CHECK-NEXT: sw a1, 0(a0)
261 store i16 -1, ptr %p, align 4
262 %gep = getelementptr i8, ptr %p, i64 2
263 store i16 -1, ptr %gep
267 define void @combine_allones_stores_2xi32(ptr %p) {
268 ; RV32-LABEL: combine_allones_stores_2xi32:
270 ; RV32-NEXT: li a1, -1
271 ; RV32-NEXT: sw a1, 0(a0)
272 ; RV32-NEXT: sw a1, 4(a0)
275 ; RV64-LABEL: combine_allones_stores_2xi32:
277 ; RV64-NEXT: li a1, -1
278 ; RV64-NEXT: sd a1, 0(a0)
280 store i32 -1, ptr %p, align 8
281 %gep = getelementptr i8, ptr %p, i64 4
282 store i32 -1, ptr %gep
286 define void @combine_allones_stores_2xi32_unaligned(ptr %p) {
287 ; CHECK-LABEL: combine_allones_stores_2xi32_unaligned:
289 ; CHECK-NEXT: li a1, -1
290 ; CHECK-NEXT: sw a1, 0(a0)
291 ; CHECK-NEXT: sw a1, 4(a0)
294 %gep = getelementptr i8, ptr %p, i64 4
295 store i32 -1, ptr %gep
299 define void @combine_allones_stores_2xi64(ptr %p) {
300 ; RV32-LABEL: combine_allones_stores_2xi64:
302 ; RV32-NEXT: li a1, -1
303 ; RV32-NEXT: sw a1, 4(a0)
304 ; RV32-NEXT: sw a1, 0(a0)
305 ; RV32-NEXT: sw a1, 12(a0)
306 ; RV32-NEXT: sw a1, 8(a0)
309 ; RV64-LABEL: combine_allones_stores_2xi64:
311 ; RV64-NEXT: li a1, -1
312 ; RV64-NEXT: sd a1, 0(a0)
313 ; RV64-NEXT: sd a1, 8(a0)
316 %gep = getelementptr i8, ptr %p, i64 8
317 store i64 -1, ptr %gep