blob: 56f3caaa4086d580e098fc9f10a701feb4dd6aba [file] [log] [blame]
Tim Northoverb4ddc082014-05-30 10:09:59 +00001; RUN: llc -mtriple=aarch64-linux-gnu -aarch64-atomic-cfg-tidy=0 -verify-machineinstrs -o - %s | FileCheck %s
Tilmann Scheller2d746bc2014-05-26 09:37:19 +00002
3; This file contains tests for the AArch64 load/store optimizer.
4
Tilmann Scheller112ada82014-05-26 12:15:51 +00005%padding = type { i8*, i8*, i8*, i8* }
6%s.word = type { i32, i32 }
7%s.doubleword = type { i64, i32 }
8%s.quadword = type { fp128, i32 }
9%s.float = type { float, i32 }
10%s.double = type { double, i32 }
11%struct.word = type { %padding, %s.word }
12%struct.doubleword = type { %padding, %s.doubleword }
13%struct.quadword = type { %padding, %s.quadword }
14%struct.float = type { %padding, %s.float }
15%struct.double = type { %padding, %s.double }
Tilmann Scheller2d746bc2014-05-26 09:37:19 +000016
17; Check the following transform:
18;
Tilmann Schellercc3ebc82014-05-26 13:36:47 +000019; (ldr|str) X, [x0, #32]
Tilmann Scheller2d746bc2014-05-26 09:37:19 +000020; ...
21; add x0, x0, #32
22; ->
Tilmann Schellercc3ebc82014-05-26 13:36:47 +000023; (ldr|str) X, [x0, #32]!
Tilmann Scheller112ada82014-05-26 12:15:51 +000024;
25; with X being either w1, x1, s0, d0 or q0.
Tilmann Scheller968d5992014-05-26 09:40:40 +000026
Tilmann Scheller112ada82014-05-26 12:15:51 +000027declare void @bar_word(%s.word*, i32)
28
29define void @load-pre-indexed-word(%struct.word* %ptr) nounwind {
30; CHECK-LABEL: load-pre-indexed-word
Tilmann Scheller2d746bc2014-05-26 09:37:19 +000031; CHECK: ldr w{{[0-9]+}}, [x{{[0-9]+}}, #32]!
32entry:
David Blaikie79e6c742015-02-27 19:29:02 +000033 %a = getelementptr inbounds %struct.word, %struct.word* %ptr, i64 0, i32 1, i32 0
David Blaikiea79ac142015-02-27 21:17:42 +000034 %add = load i32, i32* %a, align 4
Tilmann Scheller2d746bc2014-05-26 09:37:19 +000035 br label %bar
36bar:
David Blaikie79e6c742015-02-27 19:29:02 +000037 %c = getelementptr inbounds %struct.word, %struct.word* %ptr, i64 0, i32 1
Tilmann Scheller112ada82014-05-26 12:15:51 +000038 tail call void @bar_word(%s.word* %c, i32 %add)
Tilmann Scheller2d746bc2014-05-26 09:37:19 +000039 ret void
40}
41
Tilmann Schellercc3ebc82014-05-26 13:36:47 +000042define void @store-pre-indexed-word(%struct.word* %ptr, i32 %val) nounwind {
43; CHECK-LABEL: store-pre-indexed-word
44; CHECK: str w{{[0-9]+}}, [x{{[0-9]+}}, #32]!
45entry:
David Blaikie79e6c742015-02-27 19:29:02 +000046 %a = getelementptr inbounds %struct.word, %struct.word* %ptr, i64 0, i32 1, i32 0
Tilmann Schellercc3ebc82014-05-26 13:36:47 +000047 store i32 %val, i32* %a, align 4
48 br label %bar
49bar:
David Blaikie79e6c742015-02-27 19:29:02 +000050 %c = getelementptr inbounds %struct.word, %struct.word* %ptr, i64 0, i32 1
Tilmann Schellercc3ebc82014-05-26 13:36:47 +000051 tail call void @bar_word(%s.word* %c, i32 %val)
52 ret void
53}
54
Tilmann Scheller112ada82014-05-26 12:15:51 +000055declare void @bar_doubleword(%s.doubleword*, i64)
56
57define void @load-pre-indexed-doubleword(%struct.doubleword* %ptr) nounwind {
58; CHECK-LABEL: load-pre-indexed-doubleword
59; CHECK: ldr x{{[0-9]+}}, [x{{[0-9]+}}, #32]!
60entry:
David Blaikie79e6c742015-02-27 19:29:02 +000061 %a = getelementptr inbounds %struct.doubleword, %struct.doubleword* %ptr, i64 0, i32 1, i32 0
David Blaikiea79ac142015-02-27 21:17:42 +000062 %add = load i64, i64* %a, align 4
Tilmann Scheller112ada82014-05-26 12:15:51 +000063 br label %bar
64bar:
David Blaikie79e6c742015-02-27 19:29:02 +000065 %c = getelementptr inbounds %struct.doubleword, %struct.doubleword* %ptr, i64 0, i32 1
Tilmann Scheller112ada82014-05-26 12:15:51 +000066 tail call void @bar_doubleword(%s.doubleword* %c, i64 %add)
67 ret void
68}
69
Tilmann Schellercc3ebc82014-05-26 13:36:47 +000070define void @store-pre-indexed-doubleword(%struct.doubleword* %ptr, i64 %val) nounwind {
71; CHECK-LABEL: store-pre-indexed-doubleword
72; CHECK: str x{{[0-9]+}}, [x{{[0-9]+}}, #32]!
73entry:
David Blaikie79e6c742015-02-27 19:29:02 +000074 %a = getelementptr inbounds %struct.doubleword, %struct.doubleword* %ptr, i64 0, i32 1, i32 0
Tilmann Schellercc3ebc82014-05-26 13:36:47 +000075 store i64 %val, i64* %a, align 4
76 br label %bar
77bar:
David Blaikie79e6c742015-02-27 19:29:02 +000078 %c = getelementptr inbounds %struct.doubleword, %struct.doubleword* %ptr, i64 0, i32 1
Tilmann Schellercc3ebc82014-05-26 13:36:47 +000079 tail call void @bar_doubleword(%s.doubleword* %c, i64 %val)
80 ret void
81}
82
Tilmann Scheller112ada82014-05-26 12:15:51 +000083declare void @bar_quadword(%s.quadword*, fp128)
84
85define void @load-pre-indexed-quadword(%struct.quadword* %ptr) nounwind {
86; CHECK-LABEL: load-pre-indexed-quadword
87; CHECK: ldr q{{[0-9]+}}, [x{{[0-9]+}}, #32]!
88entry:
David Blaikie79e6c742015-02-27 19:29:02 +000089 %a = getelementptr inbounds %struct.quadword, %struct.quadword* %ptr, i64 0, i32 1, i32 0
David Blaikiea79ac142015-02-27 21:17:42 +000090 %add = load fp128, fp128* %a, align 4
Tilmann Scheller112ada82014-05-26 12:15:51 +000091 br label %bar
92bar:
David Blaikie79e6c742015-02-27 19:29:02 +000093 %c = getelementptr inbounds %struct.quadword, %struct.quadword* %ptr, i64 0, i32 1
Tilmann Scheller112ada82014-05-26 12:15:51 +000094 tail call void @bar_quadword(%s.quadword* %c, fp128 %add)
95 ret void
96}
97
Tilmann Schellercc3ebc82014-05-26 13:36:47 +000098define void @store-pre-indexed-quadword(%struct.quadword* %ptr, fp128 %val) nounwind {
99; CHECK-LABEL: store-pre-indexed-quadword
100; CHECK: str q{{[0-9]+}}, [x{{[0-9]+}}, #32]!
101entry:
David Blaikie79e6c742015-02-27 19:29:02 +0000102 %a = getelementptr inbounds %struct.quadword, %struct.quadword* %ptr, i64 0, i32 1, i32 0
Tilmann Schellercc3ebc82014-05-26 13:36:47 +0000103 store fp128 %val, fp128* %a, align 4
104 br label %bar
105bar:
David Blaikie79e6c742015-02-27 19:29:02 +0000106 %c = getelementptr inbounds %struct.quadword, %struct.quadword* %ptr, i64 0, i32 1
Tilmann Schellercc3ebc82014-05-26 13:36:47 +0000107 tail call void @bar_quadword(%s.quadword* %c, fp128 %val)
108 ret void
109}
110
Tilmann Scheller112ada82014-05-26 12:15:51 +0000111declare void @bar_float(%s.float*, float)
112
113define void @load-pre-indexed-float(%struct.float* %ptr) nounwind {
114; CHECK-LABEL: load-pre-indexed-float
115; CHECK: ldr s{{[0-9]+}}, [x{{[0-9]+}}, #32]!
116entry:
David Blaikie79e6c742015-02-27 19:29:02 +0000117 %a = getelementptr inbounds %struct.float, %struct.float* %ptr, i64 0, i32 1, i32 0
David Blaikiea79ac142015-02-27 21:17:42 +0000118 %add = load float, float* %a, align 4
Tilmann Scheller112ada82014-05-26 12:15:51 +0000119 br label %bar
120bar:
David Blaikie79e6c742015-02-27 19:29:02 +0000121 %c = getelementptr inbounds %struct.float, %struct.float* %ptr, i64 0, i32 1
Tilmann Scheller112ada82014-05-26 12:15:51 +0000122 tail call void @bar_float(%s.float* %c, float %add)
123 ret void
124}
125
Tilmann Schellercc3ebc82014-05-26 13:36:47 +0000126define void @store-pre-indexed-float(%struct.float* %ptr, float %val) nounwind {
127; CHECK-LABEL: store-pre-indexed-float
128; CHECK: str s{{[0-9]+}}, [x{{[0-9]+}}, #32]!
129entry:
David Blaikie79e6c742015-02-27 19:29:02 +0000130 %a = getelementptr inbounds %struct.float, %struct.float* %ptr, i64 0, i32 1, i32 0
Tilmann Schellercc3ebc82014-05-26 13:36:47 +0000131 store float %val, float* %a, align 4
132 br label %bar
133bar:
David Blaikie79e6c742015-02-27 19:29:02 +0000134 %c = getelementptr inbounds %struct.float, %struct.float* %ptr, i64 0, i32 1
Tilmann Schellercc3ebc82014-05-26 13:36:47 +0000135 tail call void @bar_float(%s.float* %c, float %val)
136 ret void
137}
138
Tilmann Scheller112ada82014-05-26 12:15:51 +0000139declare void @bar_double(%s.double*, double)
140
141define void @load-pre-indexed-double(%struct.double* %ptr) nounwind {
142; CHECK-LABEL: load-pre-indexed-double
143; CHECK: ldr d{{[0-9]+}}, [x{{[0-9]+}}, #32]!
144entry:
David Blaikie79e6c742015-02-27 19:29:02 +0000145 %a = getelementptr inbounds %struct.double, %struct.double* %ptr, i64 0, i32 1, i32 0
David Blaikiea79ac142015-02-27 21:17:42 +0000146 %add = load double, double* %a, align 4
Tilmann Scheller112ada82014-05-26 12:15:51 +0000147 br label %bar
148bar:
David Blaikie79e6c742015-02-27 19:29:02 +0000149 %c = getelementptr inbounds %struct.double, %struct.double* %ptr, i64 0, i32 1
Tilmann Scheller112ada82014-05-26 12:15:51 +0000150 tail call void @bar_double(%s.double* %c, double %add)
151 ret void
152}
Tilmann Scheller2d746bc2014-05-26 09:37:19 +0000153
Tilmann Schellercc3ebc82014-05-26 13:36:47 +0000154define void @store-pre-indexed-double(%struct.double* %ptr, double %val) nounwind {
155; CHECK-LABEL: store-pre-indexed-double
156; CHECK: str d{{[0-9]+}}, [x{{[0-9]+}}, #32]!
157entry:
David Blaikie79e6c742015-02-27 19:29:02 +0000158 %a = getelementptr inbounds %struct.double, %struct.double* %ptr, i64 0, i32 1, i32 0
Tilmann Schellercc3ebc82014-05-26 13:36:47 +0000159 store double %val, double* %a, align 4
160 br label %bar
161bar:
David Blaikie79e6c742015-02-27 19:29:02 +0000162 %c = getelementptr inbounds %struct.double, %struct.double* %ptr, i64 0, i32 1
Tilmann Schellercc3ebc82014-05-26 13:36:47 +0000163 tail call void @bar_double(%s.double* %c, double %val)
164 ret void
165}
Tilmann Scheller35e45142014-05-28 05:44:14 +0000166
167; Check the following transform:
168;
Chad Rosier1bbd7fb2015-09-25 17:48:17 +0000169; (ldp|stp) w1, w2 [x0, #32]
170; ...
171; add x0, x0, #32
172; ->
173; (ldp|stp) w1, w2, [x0, #32]!
174;
175
176define void @load-pair-pre-indexed-word(%struct.word* %ptr) nounwind {
177; CHECK-LABEL: load-pair-pre-indexed-word
178; CHECK: ldp w{{[0-9]+}}, w{{[0-9]+}}, [x0, #32]!
179; CHECK-NOT: add x0, x0, #32
180entry:
181 %a = getelementptr inbounds %struct.word, %struct.word* %ptr, i64 0, i32 1, i32 0
182 %a1 = load i32, i32* %a, align 4
183 %b = getelementptr inbounds %struct.word, %struct.word* %ptr, i64 0, i32 1, i32 1
184 %b1 = load i32, i32* %b, align 4
185 %add = add i32 %a1, %b1
186 br label %bar
187bar:
188 %c = getelementptr inbounds %struct.word, %struct.word* %ptr, i64 0, i32 1
189 tail call void @bar_word(%s.word* %c, i32 %add)
190 ret void
191}
192
193define void @store-pair-pre-indexed-word(%struct.word* %ptr, i32 %val) nounwind {
194; CHECK-LABEL: store-pair-pre-indexed-word
195; CHECK: stp w{{[0-9]+}}, w{{[0-9]+}}, [x0, #32]!
196; CHECK-NOT: add x0, x0, #32
197entry:
198 %a = getelementptr inbounds %struct.word, %struct.word* %ptr, i64 0, i32 1, i32 0
199 store i32 %val, i32* %a, align 4
200 %b = getelementptr inbounds %struct.word, %struct.word* %ptr, i64 0, i32 1, i32 1
201 store i32 %val, i32* %b, align 4
202 br label %bar
203bar:
204 %c = getelementptr inbounds %struct.word, %struct.word* %ptr, i64 0, i32 1
205 tail call void @bar_word(%s.word* %c, i32 %val)
206 ret void
207}
208
209; Check the following transform:
210;
Tilmann Schellercfbacc82014-06-02 11:57:09 +0000211; add x8, x8, #16
212; ...
213; ldr X, [x8]
214; ->
215; ldr X, [x8, #16]!
216;
217; with X being either w0, x0, s0, d0 or q0.
218
219%pre.struct.i32 = type { i32, i32, i32}
220%pre.struct.i64 = type { i32, i64, i64}
221%pre.struct.i128 = type { i32, <2 x i64>, <2 x i64>}
222%pre.struct.float = type { i32, float, float}
223%pre.struct.double = type { i32, double, double}
224
225define i32 @load-pre-indexed-word2(%pre.struct.i32** %this, i1 %cond,
226 %pre.struct.i32* %load2) nounwind {
227; CHECK-LABEL: load-pre-indexed-word2
228; CHECK: ldr w{{[0-9]+}}, [x{{[0-9]+}}, #4]!
229 br i1 %cond, label %if.then, label %if.end
230if.then:
David Blaikiea79ac142015-02-27 21:17:42 +0000231 %load1 = load %pre.struct.i32*, %pre.struct.i32** %this
David Blaikie79e6c742015-02-27 19:29:02 +0000232 %gep1 = getelementptr inbounds %pre.struct.i32, %pre.struct.i32* %load1, i64 0, i32 1
Tilmann Schellercfbacc82014-06-02 11:57:09 +0000233 br label %return
234if.end:
David Blaikie79e6c742015-02-27 19:29:02 +0000235 %gep2 = getelementptr inbounds %pre.struct.i32, %pre.struct.i32* %load2, i64 0, i32 2
Tilmann Schellercfbacc82014-06-02 11:57:09 +0000236 br label %return
237return:
238 %retptr = phi i32* [ %gep1, %if.then ], [ %gep2, %if.end ]
David Blaikiea79ac142015-02-27 21:17:42 +0000239 %ret = load i32, i32* %retptr
Tilmann Schellercfbacc82014-06-02 11:57:09 +0000240 ret i32 %ret
241}
242
243define i64 @load-pre-indexed-doubleword2(%pre.struct.i64** %this, i1 %cond,
244 %pre.struct.i64* %load2) nounwind {
245; CHECK-LABEL: load-pre-indexed-doubleword2
246; CHECK: ldr x{{[0-9]+}}, [x{{[0-9]+}}, #8]!
247 br i1 %cond, label %if.then, label %if.end
248if.then:
David Blaikiea79ac142015-02-27 21:17:42 +0000249 %load1 = load %pre.struct.i64*, %pre.struct.i64** %this
David Blaikie79e6c742015-02-27 19:29:02 +0000250 %gep1 = getelementptr inbounds %pre.struct.i64, %pre.struct.i64* %load1, i64 0, i32 1
Tilmann Schellercfbacc82014-06-02 11:57:09 +0000251 br label %return
252if.end:
David Blaikie79e6c742015-02-27 19:29:02 +0000253 %gep2 = getelementptr inbounds %pre.struct.i64, %pre.struct.i64* %load2, i64 0, i32 2
Tilmann Schellercfbacc82014-06-02 11:57:09 +0000254 br label %return
255return:
256 %retptr = phi i64* [ %gep1, %if.then ], [ %gep2, %if.end ]
David Blaikiea79ac142015-02-27 21:17:42 +0000257 %ret = load i64, i64* %retptr
Tilmann Schellercfbacc82014-06-02 11:57:09 +0000258 ret i64 %ret
259}
260
261define <2 x i64> @load-pre-indexed-quadword2(%pre.struct.i128** %this, i1 %cond,
262 %pre.struct.i128* %load2) nounwind {
263; CHECK-LABEL: load-pre-indexed-quadword2
264; CHECK: ldr q{{[0-9]+}}, [x{{[0-9]+}}, #16]!
265 br i1 %cond, label %if.then, label %if.end
266if.then:
David Blaikiea79ac142015-02-27 21:17:42 +0000267 %load1 = load %pre.struct.i128*, %pre.struct.i128** %this
David Blaikie79e6c742015-02-27 19:29:02 +0000268 %gep1 = getelementptr inbounds %pre.struct.i128, %pre.struct.i128* %load1, i64 0, i32 1
Tilmann Schellercfbacc82014-06-02 11:57:09 +0000269 br label %return
270if.end:
David Blaikie79e6c742015-02-27 19:29:02 +0000271 %gep2 = getelementptr inbounds %pre.struct.i128, %pre.struct.i128* %load2, i64 0, i32 2
Tilmann Schellercfbacc82014-06-02 11:57:09 +0000272 br label %return
273return:
274 %retptr = phi <2 x i64>* [ %gep1, %if.then ], [ %gep2, %if.end ]
David Blaikiea79ac142015-02-27 21:17:42 +0000275 %ret = load <2 x i64>, <2 x i64>* %retptr
Tilmann Schellercfbacc82014-06-02 11:57:09 +0000276 ret <2 x i64> %ret
277}
278
279define float @load-pre-indexed-float2(%pre.struct.float** %this, i1 %cond,
280 %pre.struct.float* %load2) nounwind {
281; CHECK-LABEL: load-pre-indexed-float2
282; CHECK: ldr s{{[0-9]+}}, [x{{[0-9]+}}, #4]!
283 br i1 %cond, label %if.then, label %if.end
284if.then:
David Blaikiea79ac142015-02-27 21:17:42 +0000285 %load1 = load %pre.struct.float*, %pre.struct.float** %this
David Blaikie79e6c742015-02-27 19:29:02 +0000286 %gep1 = getelementptr inbounds %pre.struct.float, %pre.struct.float* %load1, i64 0, i32 1
Tilmann Schellercfbacc82014-06-02 11:57:09 +0000287 br label %return
288if.end:
David Blaikie79e6c742015-02-27 19:29:02 +0000289 %gep2 = getelementptr inbounds %pre.struct.float, %pre.struct.float* %load2, i64 0, i32 2
Tilmann Schellercfbacc82014-06-02 11:57:09 +0000290 br label %return
291return:
292 %retptr = phi float* [ %gep1, %if.then ], [ %gep2, %if.end ]
David Blaikiea79ac142015-02-27 21:17:42 +0000293 %ret = load float, float* %retptr
Tilmann Schellercfbacc82014-06-02 11:57:09 +0000294 ret float %ret
295}
296
297define double @load-pre-indexed-double2(%pre.struct.double** %this, i1 %cond,
298 %pre.struct.double* %load2) nounwind {
299; CHECK-LABEL: load-pre-indexed-double2
300; CHECK: ldr d{{[0-9]+}}, [x{{[0-9]+}}, #8]!
301 br i1 %cond, label %if.then, label %if.end
302if.then:
David Blaikiea79ac142015-02-27 21:17:42 +0000303 %load1 = load %pre.struct.double*, %pre.struct.double** %this
David Blaikie79e6c742015-02-27 19:29:02 +0000304 %gep1 = getelementptr inbounds %pre.struct.double, %pre.struct.double* %load1, i64 0, i32 1
Tilmann Schellercfbacc82014-06-02 11:57:09 +0000305 br label %return
306if.end:
David Blaikie79e6c742015-02-27 19:29:02 +0000307 %gep2 = getelementptr inbounds %pre.struct.double, %pre.struct.double* %load2, i64 0, i32 2
Tilmann Schellercfbacc82014-06-02 11:57:09 +0000308 br label %return
309return:
310 %retptr = phi double* [ %gep1, %if.then ], [ %gep2, %if.end ]
David Blaikiea79ac142015-02-27 21:17:42 +0000311 %ret = load double, double* %retptr
Tilmann Schellercfbacc82014-06-02 11:57:09 +0000312 ret double %ret
313}
314
315; Check the following transform:
316;
Tilmann Scheller75fa6e52014-06-02 12:33:33 +0000317; add x8, x8, #16
318; ...
319; str X, [x8]
320; ->
321; str X, [x8, #16]!
322;
323; with X being either w0, x0, s0, d0 or q0.
324
325define void @store-pre-indexed-word2(%pre.struct.i32** %this, i1 %cond,
326 %pre.struct.i32* %load2,
327 i32 %val) nounwind {
328; CHECK-LABEL: store-pre-indexed-word2
329; CHECK: str w{{[0-9]+}}, [x{{[0-9]+}}, #4]!
330 br i1 %cond, label %if.then, label %if.end
331if.then:
David Blaikiea79ac142015-02-27 21:17:42 +0000332 %load1 = load %pre.struct.i32*, %pre.struct.i32** %this
David Blaikie79e6c742015-02-27 19:29:02 +0000333 %gep1 = getelementptr inbounds %pre.struct.i32, %pre.struct.i32* %load1, i64 0, i32 1
Tilmann Scheller75fa6e52014-06-02 12:33:33 +0000334 br label %return
335if.end:
David Blaikie79e6c742015-02-27 19:29:02 +0000336 %gep2 = getelementptr inbounds %pre.struct.i32, %pre.struct.i32* %load2, i64 0, i32 2
Tilmann Scheller75fa6e52014-06-02 12:33:33 +0000337 br label %return
338return:
339 %retptr = phi i32* [ %gep1, %if.then ], [ %gep2, %if.end ]
340 store i32 %val, i32* %retptr
341 ret void
342}
343
344define void @store-pre-indexed-doubleword2(%pre.struct.i64** %this, i1 %cond,
345 %pre.struct.i64* %load2,
346 i64 %val) nounwind {
347; CHECK-LABEL: store-pre-indexed-doubleword2
348; CHECK: str x{{[0-9]+}}, [x{{[0-9]+}}, #8]!
349 br i1 %cond, label %if.then, label %if.end
350if.then:
David Blaikiea79ac142015-02-27 21:17:42 +0000351 %load1 = load %pre.struct.i64*, %pre.struct.i64** %this
David Blaikie79e6c742015-02-27 19:29:02 +0000352 %gep1 = getelementptr inbounds %pre.struct.i64, %pre.struct.i64* %load1, i64 0, i32 1
Tilmann Scheller75fa6e52014-06-02 12:33:33 +0000353 br label %return
354if.end:
David Blaikie79e6c742015-02-27 19:29:02 +0000355 %gep2 = getelementptr inbounds %pre.struct.i64, %pre.struct.i64* %load2, i64 0, i32 2
Tilmann Scheller75fa6e52014-06-02 12:33:33 +0000356 br label %return
357return:
358 %retptr = phi i64* [ %gep1, %if.then ], [ %gep2, %if.end ]
359 store i64 %val, i64* %retptr
360 ret void
361}
362
363define void @store-pre-indexed-quadword2(%pre.struct.i128** %this, i1 %cond,
364 %pre.struct.i128* %load2,
365 <2 x i64> %val) nounwind {
366; CHECK-LABEL: store-pre-indexed-quadword2
367; CHECK: str q{{[0-9]+}}, [x{{[0-9]+}}, #16]!
368 br i1 %cond, label %if.then, label %if.end
369if.then:
David Blaikiea79ac142015-02-27 21:17:42 +0000370 %load1 = load %pre.struct.i128*, %pre.struct.i128** %this
David Blaikie79e6c742015-02-27 19:29:02 +0000371 %gep1 = getelementptr inbounds %pre.struct.i128, %pre.struct.i128* %load1, i64 0, i32 1
Tilmann Scheller75fa6e52014-06-02 12:33:33 +0000372 br label %return
373if.end:
David Blaikie79e6c742015-02-27 19:29:02 +0000374 %gep2 = getelementptr inbounds %pre.struct.i128, %pre.struct.i128* %load2, i64 0, i32 2
Tilmann Scheller75fa6e52014-06-02 12:33:33 +0000375 br label %return
376return:
377 %retptr = phi <2 x i64>* [ %gep1, %if.then ], [ %gep2, %if.end ]
378 store <2 x i64> %val, <2 x i64>* %retptr
379 ret void
380}
381
382define void @store-pre-indexed-float2(%pre.struct.float** %this, i1 %cond,
383 %pre.struct.float* %load2,
384 float %val) nounwind {
385; CHECK-LABEL: store-pre-indexed-float2
386; CHECK: str s{{[0-9]+}}, [x{{[0-9]+}}, #4]!
387 br i1 %cond, label %if.then, label %if.end
388if.then:
David Blaikiea79ac142015-02-27 21:17:42 +0000389 %load1 = load %pre.struct.float*, %pre.struct.float** %this
David Blaikie79e6c742015-02-27 19:29:02 +0000390 %gep1 = getelementptr inbounds %pre.struct.float, %pre.struct.float* %load1, i64 0, i32 1
Tilmann Scheller75fa6e52014-06-02 12:33:33 +0000391 br label %return
392if.end:
David Blaikie79e6c742015-02-27 19:29:02 +0000393 %gep2 = getelementptr inbounds %pre.struct.float, %pre.struct.float* %load2, i64 0, i32 2
Tilmann Scheller75fa6e52014-06-02 12:33:33 +0000394 br label %return
395return:
396 %retptr = phi float* [ %gep1, %if.then ], [ %gep2, %if.end ]
397 store float %val, float* %retptr
398 ret void
399}
400
401define void @store-pre-indexed-double2(%pre.struct.double** %this, i1 %cond,
402 %pre.struct.double* %load2,
403 double %val) nounwind {
404; CHECK-LABEL: store-pre-indexed-double2
405; CHECK: str d{{[0-9]+}}, [x{{[0-9]+}}, #8]!
406 br i1 %cond, label %if.then, label %if.end
407if.then:
David Blaikiea79ac142015-02-27 21:17:42 +0000408 %load1 = load %pre.struct.double*, %pre.struct.double** %this
David Blaikie79e6c742015-02-27 19:29:02 +0000409 %gep1 = getelementptr inbounds %pre.struct.double, %pre.struct.double* %load1, i64 0, i32 1
Tilmann Scheller75fa6e52014-06-02 12:33:33 +0000410 br label %return
411if.end:
David Blaikie79e6c742015-02-27 19:29:02 +0000412 %gep2 = getelementptr inbounds %pre.struct.double, %pre.struct.double* %load2, i64 0, i32 2
Tilmann Scheller75fa6e52014-06-02 12:33:33 +0000413 br label %return
414return:
415 %retptr = phi double* [ %gep1, %if.then ], [ %gep2, %if.end ]
416 store double %val, double* %retptr
417 ret void
418}
419
420; Check the following transform:
421;
Tilmann Scheller35e45142014-05-28 05:44:14 +0000422; ldr X, [x20]
423; ...
424; add x20, x20, #32
425; ->
426; ldr X, [x20], #32
427;
428; with X being either w0, x0, s0, d0 or q0.
429
430define void @load-post-indexed-word(i32* %array, i64 %count) nounwind {
431; CHECK-LABEL: load-post-indexed-word
432; CHECK: ldr w{{[0-9]+}}, [x{{[0-9]+}}], #16
433entry:
David Blaikie79e6c742015-02-27 19:29:02 +0000434 %gep1 = getelementptr i32, i32* %array, i64 2
Tilmann Scheller35e45142014-05-28 05:44:14 +0000435 br label %body
436
437body:
438 %iv2 = phi i32* [ %gep3, %body ], [ %gep1, %entry ]
439 %iv = phi i64 [ %iv.next, %body ], [ %count, %entry ]
David Blaikie79e6c742015-02-27 19:29:02 +0000440 %gep2 = getelementptr i32, i32* %iv2, i64 -1
David Blaikiea79ac142015-02-27 21:17:42 +0000441 %load = load i32, i32* %gep2
Tilmann Scheller35e45142014-05-28 05:44:14 +0000442 call void @use-word(i32 %load)
David Blaikiea79ac142015-02-27 21:17:42 +0000443 %load2 = load i32, i32* %iv2
Tilmann Scheller35e45142014-05-28 05:44:14 +0000444 call void @use-word(i32 %load2)
445 %iv.next = add i64 %iv, -4
David Blaikie79e6c742015-02-27 19:29:02 +0000446 %gep3 = getelementptr i32, i32* %iv2, i64 4
Tilmann Scheller35e45142014-05-28 05:44:14 +0000447 %cond = icmp eq i64 %iv.next, 0
448 br i1 %cond, label %exit, label %body
449
450exit:
451 ret void
452}
453
454define void @load-post-indexed-doubleword(i64* %array, i64 %count) nounwind {
455; CHECK-LABEL: load-post-indexed-doubleword
456; CHECK: ldr x{{[0-9]+}}, [x{{[0-9]+}}], #32
457entry:
David Blaikie79e6c742015-02-27 19:29:02 +0000458 %gep1 = getelementptr i64, i64* %array, i64 2
Tilmann Scheller35e45142014-05-28 05:44:14 +0000459 br label %body
460
461body:
462 %iv2 = phi i64* [ %gep3, %body ], [ %gep1, %entry ]
463 %iv = phi i64 [ %iv.next, %body ], [ %count, %entry ]
David Blaikie79e6c742015-02-27 19:29:02 +0000464 %gep2 = getelementptr i64, i64* %iv2, i64 -1
David Blaikiea79ac142015-02-27 21:17:42 +0000465 %load = load i64, i64* %gep2
Tilmann Scheller35e45142014-05-28 05:44:14 +0000466 call void @use-doubleword(i64 %load)
David Blaikiea79ac142015-02-27 21:17:42 +0000467 %load2 = load i64, i64* %iv2
Tilmann Scheller35e45142014-05-28 05:44:14 +0000468 call void @use-doubleword(i64 %load2)
469 %iv.next = add i64 %iv, -4
David Blaikie79e6c742015-02-27 19:29:02 +0000470 %gep3 = getelementptr i64, i64* %iv2, i64 4
Tilmann Scheller35e45142014-05-28 05:44:14 +0000471 %cond = icmp eq i64 %iv.next, 0
472 br i1 %cond, label %exit, label %body
473
474exit:
475 ret void
476}
477
478define void @load-post-indexed-quadword(<2 x i64>* %array, i64 %count) nounwind {
479; CHECK-LABEL: load-post-indexed-quadword
480; CHECK: ldr q{{[0-9]+}}, [x{{[0-9]+}}], #64
481entry:
David Blaikie79e6c742015-02-27 19:29:02 +0000482 %gep1 = getelementptr <2 x i64>, <2 x i64>* %array, i64 2
Tilmann Scheller35e45142014-05-28 05:44:14 +0000483 br label %body
484
485body:
486 %iv2 = phi <2 x i64>* [ %gep3, %body ], [ %gep1, %entry ]
487 %iv = phi i64 [ %iv.next, %body ], [ %count, %entry ]
David Blaikie79e6c742015-02-27 19:29:02 +0000488 %gep2 = getelementptr <2 x i64>, <2 x i64>* %iv2, i64 -1
David Blaikiea79ac142015-02-27 21:17:42 +0000489 %load = load <2 x i64>, <2 x i64>* %gep2
Tilmann Scheller35e45142014-05-28 05:44:14 +0000490 call void @use-quadword(<2 x i64> %load)
David Blaikiea79ac142015-02-27 21:17:42 +0000491 %load2 = load <2 x i64>, <2 x i64>* %iv2
Tilmann Scheller35e45142014-05-28 05:44:14 +0000492 call void @use-quadword(<2 x i64> %load2)
493 %iv.next = add i64 %iv, -4
David Blaikie79e6c742015-02-27 19:29:02 +0000494 %gep3 = getelementptr <2 x i64>, <2 x i64>* %iv2, i64 4
Tilmann Scheller35e45142014-05-28 05:44:14 +0000495 %cond = icmp eq i64 %iv.next, 0
496 br i1 %cond, label %exit, label %body
497
498exit:
499 ret void
500}
501
502define void @load-post-indexed-float(float* %array, i64 %count) nounwind {
503; CHECK-LABEL: load-post-indexed-float
504; CHECK: ldr s{{[0-9]+}}, [x{{[0-9]+}}], #16
505entry:
David Blaikie79e6c742015-02-27 19:29:02 +0000506 %gep1 = getelementptr float, float* %array, i64 2
Tilmann Scheller35e45142014-05-28 05:44:14 +0000507 br label %body
508
509body:
510 %iv2 = phi float* [ %gep3, %body ], [ %gep1, %entry ]
511 %iv = phi i64 [ %iv.next, %body ], [ %count, %entry ]
David Blaikie79e6c742015-02-27 19:29:02 +0000512 %gep2 = getelementptr float, float* %iv2, i64 -1
David Blaikiea79ac142015-02-27 21:17:42 +0000513 %load = load float, float* %gep2
Tilmann Scheller35e45142014-05-28 05:44:14 +0000514 call void @use-float(float %load)
David Blaikiea79ac142015-02-27 21:17:42 +0000515 %load2 = load float, float* %iv2
Tilmann Scheller35e45142014-05-28 05:44:14 +0000516 call void @use-float(float %load2)
517 %iv.next = add i64 %iv, -4
David Blaikie79e6c742015-02-27 19:29:02 +0000518 %gep3 = getelementptr float, float* %iv2, i64 4
Tilmann Scheller35e45142014-05-28 05:44:14 +0000519 %cond = icmp eq i64 %iv.next, 0
520 br i1 %cond, label %exit, label %body
521
522exit:
523 ret void
524}
525
526define void @load-post-indexed-double(double* %array, i64 %count) nounwind {
527; CHECK-LABEL: load-post-indexed-double
528; CHECK: ldr d{{[0-9]+}}, [x{{[0-9]+}}], #32
529entry:
David Blaikie79e6c742015-02-27 19:29:02 +0000530 %gep1 = getelementptr double, double* %array, i64 2
Tilmann Scheller35e45142014-05-28 05:44:14 +0000531 br label %body
532
533body:
534 %iv2 = phi double* [ %gep3, %body ], [ %gep1, %entry ]
535 %iv = phi i64 [ %iv.next, %body ], [ %count, %entry ]
David Blaikie79e6c742015-02-27 19:29:02 +0000536 %gep2 = getelementptr double, double* %iv2, i64 -1
David Blaikiea79ac142015-02-27 21:17:42 +0000537 %load = load double, double* %gep2
Tilmann Scheller35e45142014-05-28 05:44:14 +0000538 call void @use-double(double %load)
David Blaikiea79ac142015-02-27 21:17:42 +0000539 %load2 = load double, double* %iv2
Tilmann Scheller35e45142014-05-28 05:44:14 +0000540 call void @use-double(double %load2)
541 %iv.next = add i64 %iv, -4
David Blaikie79e6c742015-02-27 19:29:02 +0000542 %gep3 = getelementptr double, double* %iv2, i64 4
Tilmann Scheller35e45142014-05-28 05:44:14 +0000543 %cond = icmp eq i64 %iv.next, 0
544 br i1 %cond, label %exit, label %body
545
546exit:
547 ret void
548}
549
Tilmann Scheller7c747fc2014-05-28 06:43:00 +0000550; Check the following transform:
551;
552; str X, [x20]
553; ...
554; add x20, x20, #32
555; ->
556; str X, [x20], #32
557;
558; with X being either w0, x0, s0, d0 or q0.
559
560define void @store-post-indexed-word(i32* %array, i64 %count, i32 %val) nounwind {
561; CHECK-LABEL: store-post-indexed-word
562; CHECK: str w{{[0-9]+}}, [x{{[0-9]+}}], #16
563entry:
David Blaikie79e6c742015-02-27 19:29:02 +0000564 %gep1 = getelementptr i32, i32* %array, i64 2
Tilmann Scheller7c747fc2014-05-28 06:43:00 +0000565 br label %body
566
567body:
568 %iv2 = phi i32* [ %gep3, %body ], [ %gep1, %entry ]
569 %iv = phi i64 [ %iv.next, %body ], [ %count, %entry ]
David Blaikie79e6c742015-02-27 19:29:02 +0000570 %gep2 = getelementptr i32, i32* %iv2, i64 -1
David Blaikiea79ac142015-02-27 21:17:42 +0000571 %load = load i32, i32* %gep2
Tilmann Scheller7c747fc2014-05-28 06:43:00 +0000572 call void @use-word(i32 %load)
573 store i32 %val, i32* %iv2
574 %iv.next = add i64 %iv, -4
David Blaikie79e6c742015-02-27 19:29:02 +0000575 %gep3 = getelementptr i32, i32* %iv2, i64 4
Tilmann Scheller7c747fc2014-05-28 06:43:00 +0000576 %cond = icmp eq i64 %iv.next, 0
577 br i1 %cond, label %exit, label %body
578
579exit:
580 ret void
581}
582
583define void @store-post-indexed-doubleword(i64* %array, i64 %count, i64 %val) nounwind {
584; CHECK-LABEL: store-post-indexed-doubleword
585; CHECK: str x{{[0-9]+}}, [x{{[0-9]+}}], #32
586entry:
David Blaikie79e6c742015-02-27 19:29:02 +0000587 %gep1 = getelementptr i64, i64* %array, i64 2
Tilmann Scheller7c747fc2014-05-28 06:43:00 +0000588 br label %body
589
590body:
591 %iv2 = phi i64* [ %gep3, %body ], [ %gep1, %entry ]
592 %iv = phi i64 [ %iv.next, %body ], [ %count, %entry ]
David Blaikie79e6c742015-02-27 19:29:02 +0000593 %gep2 = getelementptr i64, i64* %iv2, i64 -1
David Blaikiea79ac142015-02-27 21:17:42 +0000594 %load = load i64, i64* %gep2
Tilmann Scheller7c747fc2014-05-28 06:43:00 +0000595 call void @use-doubleword(i64 %load)
596 store i64 %val, i64* %iv2
597 %iv.next = add i64 %iv, -4
David Blaikie79e6c742015-02-27 19:29:02 +0000598 %gep3 = getelementptr i64, i64* %iv2, i64 4
Tilmann Scheller7c747fc2014-05-28 06:43:00 +0000599 %cond = icmp eq i64 %iv.next, 0
600 br i1 %cond, label %exit, label %body
601
602exit:
603 ret void
604}
605
606define void @store-post-indexed-quadword(<2 x i64>* %array, i64 %count, <2 x i64> %val) nounwind {
607; CHECK-LABEL: store-post-indexed-quadword
608; CHECK: str q{{[0-9]+}}, [x{{[0-9]+}}], #64
609entry:
David Blaikie79e6c742015-02-27 19:29:02 +0000610 %gep1 = getelementptr <2 x i64>, <2 x i64>* %array, i64 2
Tilmann Scheller7c747fc2014-05-28 06:43:00 +0000611 br label %body
612
613body:
614 %iv2 = phi <2 x i64>* [ %gep3, %body ], [ %gep1, %entry ]
615 %iv = phi i64 [ %iv.next, %body ], [ %count, %entry ]
David Blaikie79e6c742015-02-27 19:29:02 +0000616 %gep2 = getelementptr <2 x i64>, <2 x i64>* %iv2, i64 -1
David Blaikiea79ac142015-02-27 21:17:42 +0000617 %load = load <2 x i64>, <2 x i64>* %gep2
Tilmann Scheller7c747fc2014-05-28 06:43:00 +0000618 call void @use-quadword(<2 x i64> %load)
619 store <2 x i64> %val, <2 x i64>* %iv2
620 %iv.next = add i64 %iv, -4
David Blaikie79e6c742015-02-27 19:29:02 +0000621 %gep3 = getelementptr <2 x i64>, <2 x i64>* %iv2, i64 4
Tilmann Scheller7c747fc2014-05-28 06:43:00 +0000622 %cond = icmp eq i64 %iv.next, 0
623 br i1 %cond, label %exit, label %body
624
625exit:
626 ret void
627}
628
629define void @store-post-indexed-float(float* %array, i64 %count, float %val) nounwind {
630; CHECK-LABEL: store-post-indexed-float
631; CHECK: str s{{[0-9]+}}, [x{{[0-9]+}}], #16
632entry:
David Blaikie79e6c742015-02-27 19:29:02 +0000633 %gep1 = getelementptr float, float* %array, i64 2
Tilmann Scheller7c747fc2014-05-28 06:43:00 +0000634 br label %body
635
636body:
637 %iv2 = phi float* [ %gep3, %body ], [ %gep1, %entry ]
638 %iv = phi i64 [ %iv.next, %body ], [ %count, %entry ]
David Blaikie79e6c742015-02-27 19:29:02 +0000639 %gep2 = getelementptr float, float* %iv2, i64 -1
David Blaikiea79ac142015-02-27 21:17:42 +0000640 %load = load float, float* %gep2
Tilmann Scheller7c747fc2014-05-28 06:43:00 +0000641 call void @use-float(float %load)
642 store float %val, float* %iv2
643 %iv.next = add i64 %iv, -4
David Blaikie79e6c742015-02-27 19:29:02 +0000644 %gep3 = getelementptr float, float* %iv2, i64 4
Tilmann Scheller7c747fc2014-05-28 06:43:00 +0000645 %cond = icmp eq i64 %iv.next, 0
646 br i1 %cond, label %exit, label %body
647
648exit:
649 ret void
650}
651
652define void @store-post-indexed-double(double* %array, i64 %count, double %val) nounwind {
653; CHECK-LABEL: store-post-indexed-double
654; CHECK: str d{{[0-9]+}}, [x{{[0-9]+}}], #32
655entry:
David Blaikie79e6c742015-02-27 19:29:02 +0000656 %gep1 = getelementptr double, double* %array, i64 2
Tilmann Scheller7c747fc2014-05-28 06:43:00 +0000657 br label %body
658
659body:
660 %iv2 = phi double* [ %gep3, %body ], [ %gep1, %entry ]
661 %iv = phi i64 [ %iv.next, %body ], [ %count, %entry ]
David Blaikie79e6c742015-02-27 19:29:02 +0000662 %gep2 = getelementptr double, double* %iv2, i64 -1
David Blaikiea79ac142015-02-27 21:17:42 +0000663 %load = load double, double* %gep2
Tilmann Scheller7c747fc2014-05-28 06:43:00 +0000664 call void @use-double(double %load)
665 store double %val, double* %iv2
666 %iv.next = add i64 %iv, -4
David Blaikie79e6c742015-02-27 19:29:02 +0000667 %gep3 = getelementptr double, double* %iv2, i64 4
Tilmann Scheller7c747fc2014-05-28 06:43:00 +0000668 %cond = icmp eq i64 %iv.next, 0
669 br i1 %cond, label %exit, label %body
670
671exit:
672 ret void
673}
674
Tilmann Scheller35e45142014-05-28 05:44:14 +0000675declare void @use-word(i32)
676declare void @use-doubleword(i64)
677declare void @use-quadword(<2 x i64>)
678declare void @use-float(float)
679declare void @use-double(double)
Tilmann Scheller2a7efeb2014-06-03 16:03:00 +0000680
681; Check the following transform:
682;
Chad Rosier1bbd7fb2015-09-25 17:48:17 +0000683; stp w0, [x20]
684; ...
685; add x20, x20, #32
686; ->
687; stp w0, [x20], #32
688
689define void @store-pair-post-indexed-word() nounwind {
690; CHECK-LABEL: store-pair-post-indexed-word
691; CHECK: stp w{{[0-9]+}}, w{{[0-9]+}}, [sp], #16
692; CHECK: ret
693 %src = alloca { i32, i32 }, align 8
694 %dst = alloca { i32, i32 }, align 8
695
696 %src.realp = getelementptr inbounds { i32, i32 }, { i32, i32 }* %src, i32 0, i32 0
697 %src.real = load i32, i32* %src.realp
698 %src.imagp = getelementptr inbounds { i32, i32 }, { i32, i32 }* %src, i32 0, i32 1
699 %src.imag = load i32, i32* %src.imagp
700
701 %dst.realp = getelementptr inbounds { i32, i32 }, { i32, i32 }* %dst, i32 0, i32 0
702 %dst.imagp = getelementptr inbounds { i32, i32 }, { i32, i32 }* %dst, i32 0, i32 1
703 store i32 %src.real, i32* %dst.realp
704 store i32 %src.imag, i32* %dst.imagp
705 ret void
706}
707
708define void @store-pair-post-indexed-doubleword() nounwind {
709; CHECK-LABEL: store-pair-post-indexed-doubleword
710; CHECK: stp x{{[0-9]+}}, x{{[0-9]+}}, [sp], #32
711; CHECK: ret
712 %src = alloca { i64, i64 }, align 8
713 %dst = alloca { i64, i64 }, align 8
714
715 %src.realp = getelementptr inbounds { i64, i64 }, { i64, i64 }* %src, i32 0, i32 0
716 %src.real = load i64, i64* %src.realp
717 %src.imagp = getelementptr inbounds { i64, i64 }, { i64, i64 }* %src, i32 0, i32 1
718 %src.imag = load i64, i64* %src.imagp
719
720 %dst.realp = getelementptr inbounds { i64, i64 }, { i64, i64 }* %dst, i32 0, i32 0
721 %dst.imagp = getelementptr inbounds { i64, i64 }, { i64, i64 }* %dst, i32 0, i32 1
722 store i64 %src.real, i64* %dst.realp
723 store i64 %src.imag, i64* %dst.imagp
724 ret void
725}
726
727define void @store-pair-post-indexed-float() nounwind {
728; CHECK-LABEL: store-pair-post-indexed-float
729; CHECK: stp s{{[0-9]+}}, s{{[0-9]+}}, [sp], #16
730; CHECK: ret
731 %src = alloca { float, float }, align 8
732 %dst = alloca { float, float }, align 8
733
734 %src.realp = getelementptr inbounds { float, float }, { float, float }* %src, i32 0, i32 0
735 %src.real = load float, float* %src.realp
736 %src.imagp = getelementptr inbounds { float, float }, { float, float }* %src, i32 0, i32 1
737 %src.imag = load float, float* %src.imagp
738
739 %dst.realp = getelementptr inbounds { float, float }, { float, float }* %dst, i32 0, i32 0
740 %dst.imagp = getelementptr inbounds { float, float }, { float, float }* %dst, i32 0, i32 1
741 store float %src.real, float* %dst.realp
742 store float %src.imag, float* %dst.imagp
743 ret void
744}
745
746define void @store-pair-post-indexed-double() nounwind {
747; CHECK-LABEL: store-pair-post-indexed-double
748; CHECK: stp d{{[0-9]+}}, d{{[0-9]+}}, [sp], #32
749; CHECK: ret
750 %src = alloca { double, double }, align 8
751 %dst = alloca { double, double }, align 8
752
753 %src.realp = getelementptr inbounds { double, double }, { double, double }* %src, i32 0, i32 0
754 %src.real = load double, double* %src.realp
755 %src.imagp = getelementptr inbounds { double, double }, { double, double }* %src, i32 0, i32 1
756 %src.imag = load double, double* %src.imagp
757
758 %dst.realp = getelementptr inbounds { double, double }, { double, double }* %dst, i32 0, i32 0
759 %dst.imagp = getelementptr inbounds { double, double }, { double, double }* %dst, i32 0, i32 1
760 store double %src.real, double* %dst.realp
761 store double %src.imag, double* %dst.imagp
762 ret void
763}
764
765; Check the following transform:
766;
Tilmann Scheller2a7efeb2014-06-03 16:03:00 +0000767; (ldr|str) X, [x20]
768; ...
769; sub x20, x20, #16
770; ->
771; (ldr|str) X, [x20], #-16
772;
773; with X being either w0, x0, s0, d0 or q0.
774
775define void @post-indexed-sub-word(i32* %a, i32* %b, i64 %count) nounwind {
776; CHECK-LABEL: post-indexed-sub-word
777; CHECK: ldr w{{[0-9]+}}, [x{{[0-9]+}}], #-8
778; CHECK: str w{{[0-9]+}}, [x{{[0-9]+}}], #-8
779 br label %for.body
780for.body:
781 %phi1 = phi i32* [ %gep4, %for.body ], [ %b, %0 ]
782 %phi2 = phi i32* [ %gep3, %for.body ], [ %a, %0 ]
783 %i = phi i64 [ %dec.i, %for.body], [ %count, %0 ]
David Blaikie79e6c742015-02-27 19:29:02 +0000784 %gep1 = getelementptr i32, i32* %phi1, i64 -1
David Blaikiea79ac142015-02-27 21:17:42 +0000785 %load1 = load i32, i32* %gep1
David Blaikie79e6c742015-02-27 19:29:02 +0000786 %gep2 = getelementptr i32, i32* %phi2, i64 -1
Tilmann Scheller2a7efeb2014-06-03 16:03:00 +0000787 store i32 %load1, i32* %gep2
David Blaikiea79ac142015-02-27 21:17:42 +0000788 %load2 = load i32, i32* %phi1
Tilmann Scheller2a7efeb2014-06-03 16:03:00 +0000789 store i32 %load2, i32* %phi2
790 %dec.i = add nsw i64 %i, -1
David Blaikie79e6c742015-02-27 19:29:02 +0000791 %gep3 = getelementptr i32, i32* %phi2, i64 -2
792 %gep4 = getelementptr i32, i32* %phi1, i64 -2
Tilmann Scheller2a7efeb2014-06-03 16:03:00 +0000793 %cond = icmp sgt i64 %dec.i, 0
794 br i1 %cond, label %for.body, label %end
795end:
796 ret void
797}
798
799define void @post-indexed-sub-doubleword(i64* %a, i64* %b, i64 %count) nounwind {
800; CHECK-LABEL: post-indexed-sub-doubleword
801; CHECK: ldr x{{[0-9]+}}, [x{{[0-9]+}}], #-16
802; CHECK: str x{{[0-9]+}}, [x{{[0-9]+}}], #-16
803 br label %for.body
804for.body:
805 %phi1 = phi i64* [ %gep4, %for.body ], [ %b, %0 ]
806 %phi2 = phi i64* [ %gep3, %for.body ], [ %a, %0 ]
807 %i = phi i64 [ %dec.i, %for.body], [ %count, %0 ]
David Blaikie79e6c742015-02-27 19:29:02 +0000808 %gep1 = getelementptr i64, i64* %phi1, i64 -1
David Blaikiea79ac142015-02-27 21:17:42 +0000809 %load1 = load i64, i64* %gep1
David Blaikie79e6c742015-02-27 19:29:02 +0000810 %gep2 = getelementptr i64, i64* %phi2, i64 -1
Tilmann Scheller2a7efeb2014-06-03 16:03:00 +0000811 store i64 %load1, i64* %gep2
David Blaikiea79ac142015-02-27 21:17:42 +0000812 %load2 = load i64, i64* %phi1
Tilmann Scheller2a7efeb2014-06-03 16:03:00 +0000813 store i64 %load2, i64* %phi2
814 %dec.i = add nsw i64 %i, -1
David Blaikie79e6c742015-02-27 19:29:02 +0000815 %gep3 = getelementptr i64, i64* %phi2, i64 -2
816 %gep4 = getelementptr i64, i64* %phi1, i64 -2
Tilmann Scheller2a7efeb2014-06-03 16:03:00 +0000817 %cond = icmp sgt i64 %dec.i, 0
818 br i1 %cond, label %for.body, label %end
819end:
820 ret void
821}
822
823define void @post-indexed-sub-quadword(<2 x i64>* %a, <2 x i64>* %b, i64 %count) nounwind {
824; CHECK-LABEL: post-indexed-sub-quadword
825; CHECK: ldr q{{[0-9]+}}, [x{{[0-9]+}}], #-32
826; CHECK: str q{{[0-9]+}}, [x{{[0-9]+}}], #-32
827 br label %for.body
828for.body:
829 %phi1 = phi <2 x i64>* [ %gep4, %for.body ], [ %b, %0 ]
830 %phi2 = phi <2 x i64>* [ %gep3, %for.body ], [ %a, %0 ]
831 %i = phi i64 [ %dec.i, %for.body], [ %count, %0 ]
David Blaikie79e6c742015-02-27 19:29:02 +0000832 %gep1 = getelementptr <2 x i64>, <2 x i64>* %phi1, i64 -1
David Blaikiea79ac142015-02-27 21:17:42 +0000833 %load1 = load <2 x i64>, <2 x i64>* %gep1
David Blaikie79e6c742015-02-27 19:29:02 +0000834 %gep2 = getelementptr <2 x i64>, <2 x i64>* %phi2, i64 -1
Tilmann Scheller2a7efeb2014-06-03 16:03:00 +0000835 store <2 x i64> %load1, <2 x i64>* %gep2
David Blaikiea79ac142015-02-27 21:17:42 +0000836 %load2 = load <2 x i64>, <2 x i64>* %phi1
Tilmann Scheller2a7efeb2014-06-03 16:03:00 +0000837 store <2 x i64> %load2, <2 x i64>* %phi2
838 %dec.i = add nsw i64 %i, -1
David Blaikie79e6c742015-02-27 19:29:02 +0000839 %gep3 = getelementptr <2 x i64>, <2 x i64>* %phi2, i64 -2
840 %gep4 = getelementptr <2 x i64>, <2 x i64>* %phi1, i64 -2
Tilmann Scheller2a7efeb2014-06-03 16:03:00 +0000841 %cond = icmp sgt i64 %dec.i, 0
842 br i1 %cond, label %for.body, label %end
843end:
844 ret void
845}
846
847define void @post-indexed-sub-float(float* %a, float* %b, i64 %count) nounwind {
848; CHECK-LABEL: post-indexed-sub-float
849; CHECK: ldr s{{[0-9]+}}, [x{{[0-9]+}}], #-8
850; CHECK: str s{{[0-9]+}}, [x{{[0-9]+}}], #-8
851 br label %for.body
852for.body:
853 %phi1 = phi float* [ %gep4, %for.body ], [ %b, %0 ]
854 %phi2 = phi float* [ %gep3, %for.body ], [ %a, %0 ]
855 %i = phi i64 [ %dec.i, %for.body], [ %count, %0 ]
David Blaikie79e6c742015-02-27 19:29:02 +0000856 %gep1 = getelementptr float, float* %phi1, i64 -1
David Blaikiea79ac142015-02-27 21:17:42 +0000857 %load1 = load float, float* %gep1
David Blaikie79e6c742015-02-27 19:29:02 +0000858 %gep2 = getelementptr float, float* %phi2, i64 -1
Tilmann Scheller2a7efeb2014-06-03 16:03:00 +0000859 store float %load1, float* %gep2
David Blaikiea79ac142015-02-27 21:17:42 +0000860 %load2 = load float, float* %phi1
Tilmann Scheller2a7efeb2014-06-03 16:03:00 +0000861 store float %load2, float* %phi2
862 %dec.i = add nsw i64 %i, -1
David Blaikie79e6c742015-02-27 19:29:02 +0000863 %gep3 = getelementptr float, float* %phi2, i64 -2
864 %gep4 = getelementptr float, float* %phi1, i64 -2
Tilmann Scheller2a7efeb2014-06-03 16:03:00 +0000865 %cond = icmp sgt i64 %dec.i, 0
866 br i1 %cond, label %for.body, label %end
867end:
868 ret void
869}
870
871define void @post-indexed-sub-double(double* %a, double* %b, i64 %count) nounwind {
872; CHECK-LABEL: post-indexed-sub-double
873; CHECK: ldr d{{[0-9]+}}, [x{{[0-9]+}}], #-16
874; CHECK: str d{{[0-9]+}}, [x{{[0-9]+}}], #-16
875 br label %for.body
876for.body:
877 %phi1 = phi double* [ %gep4, %for.body ], [ %b, %0 ]
878 %phi2 = phi double* [ %gep3, %for.body ], [ %a, %0 ]
879 %i = phi i64 [ %dec.i, %for.body], [ %count, %0 ]
David Blaikie79e6c742015-02-27 19:29:02 +0000880 %gep1 = getelementptr double, double* %phi1, i64 -1
David Blaikiea79ac142015-02-27 21:17:42 +0000881 %load1 = load double, double* %gep1
David Blaikie79e6c742015-02-27 19:29:02 +0000882 %gep2 = getelementptr double, double* %phi2, i64 -1
Tilmann Scheller2a7efeb2014-06-03 16:03:00 +0000883 store double %load1, double* %gep2
David Blaikiea79ac142015-02-27 21:17:42 +0000884 %load2 = load double, double* %phi1
Tilmann Scheller2a7efeb2014-06-03 16:03:00 +0000885 store double %load2, double* %phi2
886 %dec.i = add nsw i64 %i, -1
David Blaikie79e6c742015-02-27 19:29:02 +0000887 %gep3 = getelementptr double, double* %phi2, i64 -2
888 %gep4 = getelementptr double, double* %phi1, i64 -2
Tilmann Scheller2a7efeb2014-06-03 16:03:00 +0000889 %cond = icmp sgt i64 %dec.i, 0
890 br i1 %cond, label %for.body, label %end
891end:
892 ret void
893}