1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-linux-gnu | FileCheck %s
4 define i64 @addimm_mulimm_accept_00(i64 %a) {
5 ; CHECK-LABEL: addimm_mulimm_accept_00:
7 ; CHECK-NEXT: mov w8, #37 // =0x25
8 ; CHECK-NEXT: mov x9, #1147 // =0x47b
9 ; CHECK-NEXT: madd x0, x0, x8, x9
11 %tmp0 = add i64 %a, 31
12 %tmp1 = mul i64 %tmp0, 37
16 define i64 @addimm_mulimm_accept_01(i64 %a) {
17 ; CHECK-LABEL: addimm_mulimm_accept_01:
19 ; CHECK-NEXT: mov w8, #37 // =0x25
20 ; CHECK-NEXT: mov x9, #-1147 // =0xfffffffffffffb85
21 ; CHECK-NEXT: madd x0, x0, x8, x9
23 %tmp0 = add i64 %a, -31
24 %tmp1 = mul i64 %tmp0, 37
28 define signext i32 @addimm_mulimm_accept_02(i32 signext %a) {
29 ; CHECK-LABEL: addimm_mulimm_accept_02:
31 ; CHECK-NEXT: mov w8, #37 // =0x25
32 ; CHECK-NEXT: mov w9, #1147 // =0x47b
33 ; CHECK-NEXT: madd w0, w0, w8, w9
35 %tmp0 = add i32 %a, 31
36 %tmp1 = mul i32 %tmp0, 37
40 define signext i32 @addimm_mulimm_accept_03(i32 signext %a) {
41 ; CHECK-LABEL: addimm_mulimm_accept_03:
43 ; CHECK-NEXT: mov w8, #37 // =0x25
44 ; CHECK-NEXT: mov w9, #-1147 // =0xfffffb85
45 ; CHECK-NEXT: madd w0, w0, w8, w9
47 %tmp0 = add i32 %a, -31
48 %tmp1 = mul i32 %tmp0, 37
52 define i64 @addimm_mulimm_accept_10(i64 %a) {
53 ; CHECK-LABEL: addimm_mulimm_accept_10:
55 ; CHECK-NEXT: mov w8, #37 // =0x25
56 ; CHECK-NEXT: mov w9, #32888 // =0x8078
57 ; CHECK-NEXT: movk w9, #17, lsl #16
58 ; CHECK-NEXT: madd x0, x0, x8, x9
60 %tmp0 = add i64 %a, 31000
61 %tmp1 = mul i64 %tmp0, 37
65 define i64 @addimm_mulimm_accept_11(i64 %a) {
66 ; CHECK-LABEL: addimm_mulimm_accept_11:
68 ; CHECK-NEXT: mov w8, #37 // =0x25
69 ; CHECK-NEXT: mov x9, #-32888 // =0xffffffffffff7f88
70 ; CHECK-NEXT: movk x9, #65518, lsl #16
71 ; CHECK-NEXT: madd x0, x0, x8, x9
73 %tmp0 = add i64 %a, -31000
74 %tmp1 = mul i64 %tmp0, 37
78 define signext i32 @addimm_mulimm_accept_12(i32 signext %a) {
79 ; CHECK-LABEL: addimm_mulimm_accept_12:
81 ; CHECK-NEXT: mov w8, #37 // =0x25
82 ; CHECK-NEXT: mov w9, #32888 // =0x8078
83 ; CHECK-NEXT: movk w9, #17, lsl #16
84 ; CHECK-NEXT: madd w0, w0, w8, w9
86 %tmp0 = add i32 %a, 31000
87 %tmp1 = mul i32 %tmp0, 37
91 define signext i32 @addimm_mulimm_accept_13(i32 signext %a) {
92 ; CHECK-LABEL: addimm_mulimm_accept_13:
94 ; CHECK-NEXT: mov w8, #37 // =0x25
95 ; CHECK-NEXT: mov w9, #32648 // =0x7f88
96 ; CHECK-NEXT: movk w9, #65518, lsl #16
97 ; CHECK-NEXT: madd w0, w0, w8, w9
99 %tmp0 = add i32 %a, -31000
100 %tmp1 = mul i32 %tmp0, 37
104 define i64 @addimm_mulimm_reject_00(i64 %a) {
105 ; CHECK-LABEL: addimm_mulimm_reject_00:
107 ; CHECK-NEXT: mov w8, #3700 // =0xe74
108 ; CHECK-NEXT: add x9, x0, #3100
109 ; CHECK-NEXT: mul x0, x9, x8
111 %tmp0 = add i64 %a, 3100
112 %tmp1 = mul i64 %tmp0, 3700
116 define i64 @addimm_mulimm_reject_01(i64 %a) {
117 ; CHECK-LABEL: addimm_mulimm_reject_01:
119 ; CHECK-NEXT: mov w8, #3700 // =0xe74
120 ; CHECK-NEXT: sub x9, x0, #3100
121 ; CHECK-NEXT: mul x0, x9, x8
123 %tmp0 = add i64 %a, -3100
124 %tmp1 = mul i64 %tmp0, 3700
128 define signext i32 @addimm_mulimm_reject_02(i32 signext %a) {
129 ; CHECK-LABEL: addimm_mulimm_reject_02:
131 ; CHECK-NEXT: mov w8, #3700 // =0xe74
132 ; CHECK-NEXT: add w9, w0, #3100
133 ; CHECK-NEXT: mul w0, w9, w8
135 %tmp0 = add i32 %a, 3100
136 %tmp1 = mul i32 %tmp0, 3700
140 define signext i32 @addimm_mulimm_reject_03(i32 signext %a) {
141 ; CHECK-LABEL: addimm_mulimm_reject_03:
143 ; CHECK-NEXT: mov w8, #3700 // =0xe74
144 ; CHECK-NEXT: sub w9, w0, #3100
145 ; CHECK-NEXT: mul w0, w9, w8
147 %tmp0 = add i32 %a, -3100
148 %tmp1 = mul i32 %tmp0, 3700
152 define signext i32 @addmuladd(i32 signext %a) {
153 ; CHECK-LABEL: addmuladd:
155 ; CHECK-NEXT: mov w8, #324 // =0x144
156 ; CHECK-NEXT: mov w9, #1300 // =0x514
157 ; CHECK-NEXT: madd w0, w0, w8, w9
159 %tmp0 = add i32 %a, 4
160 %tmp1 = mul i32 %tmp0, 324
161 %tmp2 = add i32 %tmp1, 4
165 define signext i32 @addmuladd_multiuse(i32 signext %a) {
166 ; CHECK-LABEL: addmuladd_multiuse:
168 ; CHECK-NEXT: mov w8, #324 // =0x144
169 ; CHECK-NEXT: mov w9, #1300 // =0x514
170 ; CHECK-NEXT: madd w8, w0, w8, w9
171 ; CHECK-NEXT: add w9, w0, #4
172 ; CHECK-NEXT: eor w0, w9, w8
174 %tmp0 = add i32 %a, 4
175 %tmp1 = mul i32 %tmp0, 324
176 %tmp2 = add i32 %tmp1, 4
177 %tmp3 = xor i32 %tmp0, %tmp2
181 define signext i32 @addmuladd_multiusemul(i32 signext %a) {
182 ; CHECK-LABEL: addmuladd_multiusemul:
184 ; CHECK-NEXT: mov w8, #324 // =0x144
185 ; CHECK-NEXT: mul w8, w0, w8
186 ; CHECK-NEXT: add w9, w8, #1296
187 ; CHECK-NEXT: add w8, w8, #1300
188 ; CHECK-NEXT: eor w0, w9, w8
190 %tmp0 = add i32 %a, 4
191 %tmp1 = mul i32 %tmp0, 324
192 %tmp2 = add i32 %tmp1, 4
193 %tmp3 = xor i32 %tmp1, %tmp2
197 define signext i32 @addmuladd_multiuse2(i32 signext %a) {
198 ; CHECK-LABEL: addmuladd_multiuse2:
200 ; CHECK-NEXT: mov w8, #324 // =0x144
201 ; CHECK-NEXT: lsl w9, w0, #2
202 ; CHECK-NEXT: mov w10, #1300 // =0x514
203 ; CHECK-NEXT: madd w8, w0, w8, w10
204 ; CHECK-NEXT: add w9, w9, #20
205 ; CHECK-NEXT: eor w0, w8, w9
207 %tmp0 = add i32 %a, 4
208 %tmp1 = mul i32 %tmp0, 4
209 %tmp2 = add i32 %tmp1, 4
210 %tmp3 = mul i32 %tmp0, 324
211 %tmp4 = add i32 %tmp3, 4
212 %tmp5 = xor i32 %tmp4, %tmp2
216 define signext i32 @addaddmuladd(i32 signext %a, i32 %b) {
217 ; CHECK-LABEL: addaddmuladd:
219 ; CHECK-NEXT: mov w8, #324 // =0x144
220 ; CHECK-NEXT: madd w8, w0, w8, w1
221 ; CHECK-NEXT: add w0, w8, #1300
223 %tmp0 = add i32 %a, 4
224 %tmp1 = mul i32 %tmp0, 324
225 %tmp2 = add i32 %tmp1, %b
226 %tmp3 = add i32 %tmp2, 4
230 define signext i32 @addaddmuladd_multiuse(i32 signext %a, i32 %b) {
231 ; CHECK-LABEL: addaddmuladd_multiuse:
233 ; CHECK-NEXT: mov w8, #324 // =0x144
234 ; CHECK-NEXT: add w9, w0, #4
235 ; CHECK-NEXT: madd w8, w0, w8, w1
236 ; CHECK-NEXT: add w8, w8, #1300
237 ; CHECK-NEXT: eor w0, w9, w8
239 %tmp0 = add i32 %a, 4
240 %tmp1 = mul i32 %tmp0, 324
241 %tmp2 = add i32 %tmp1, %b
242 %tmp3 = add i32 %tmp2, 4
243 %tmp4 = xor i32 %tmp0, %tmp3
247 define signext i32 @addaddmuladd_multiuse2(i32 signext %a, i32 %b) {
248 ; CHECK-LABEL: addaddmuladd_multiuse2:
250 ; CHECK-NEXT: mov w8, #324 // =0x144
251 ; CHECK-NEXT: mov w9, #162 // =0xa2
252 ; CHECK-NEXT: madd w8, w0, w8, w1
253 ; CHECK-NEXT: madd w9, w0, w9, w1
254 ; CHECK-NEXT: add w8, w8, #1300
255 ; CHECK-NEXT: add w9, w9, #652
256 ; CHECK-NEXT: eor w0, w9, w8
258 %tmp0 = add i32 %a, 4
259 %tmp1 = mul i32 %tmp0, 324
260 %tmp2 = add i32 %tmp1, %b
261 %tmp3 = add i32 %tmp2, 4
262 %tmp1b = mul i32 %tmp0, 162
263 %tmp2b = add i32 %tmp1b, %b
264 %tmp3b = add i32 %tmp2b, 4
265 %tmp4 = xor i32 %tmp3b, %tmp3
269 define <4 x i32> @addmuladd_vec(<4 x i32> %a) {
270 ; CHECK-LABEL: addmuladd_vec:
272 ; CHECK-NEXT: mov w8, #324 // =0x144
273 ; CHECK-NEXT: mov w9, #1300 // =0x514
274 ; CHECK-NEXT: dup v2.4s, w8
275 ; CHECK-NEXT: dup v1.4s, w9
276 ; CHECK-NEXT: mla v1.4s, v0.4s, v2.4s
277 ; CHECK-NEXT: mov v0.16b, v1.16b
279 %tmp0 = add <4 x i32> %a, <i32 4, i32 4, i32 4, i32 4>
280 %tmp1 = mul <4 x i32> %tmp0, <i32 324, i32 324, i32 324, i32 324>
281 %tmp2 = add <4 x i32> %tmp1, <i32 4, i32 4, i32 4, i32 4>
285 define <4 x i32> @addmuladd_vec_multiuse(<4 x i32> %a) {
286 ; CHECK-LABEL: addmuladd_vec_multiuse:
288 ; CHECK-NEXT: movi v1.4s, #4
289 ; CHECK-NEXT: mov w8, #324 // =0x144
290 ; CHECK-NEXT: dup v2.4s, w8
291 ; CHECK-NEXT: add v0.4s, v0.4s, v1.4s
292 ; CHECK-NEXT: mla v1.4s, v0.4s, v2.4s
293 ; CHECK-NEXT: eor v0.16b, v0.16b, v1.16b
295 %tmp0 = add <4 x i32> %a, <i32 4, i32 4, i32 4, i32 4>
296 %tmp1 = mul <4 x i32> %tmp0, <i32 324, i32 324, i32 324, i32 324>
297 %tmp2 = add <4 x i32> %tmp1, <i32 4, i32 4, i32 4, i32 4>
298 %tmp3 = xor <4 x i32> %tmp0, %tmp2
302 define void @addmuladd_gep(ptr %p, i64 %a) {
303 ; CHECK-LABEL: addmuladd_gep:
305 ; CHECK-NEXT: mov w8, #40 // =0x28
306 ; CHECK-NEXT: str wzr, [x0, #10]!
307 ; CHECK-NEXT: madd x8, x1, x8, x0
308 ; CHECK-NEXT: str wzr, [x8, #20]
310 %q = getelementptr i8, ptr %p, i64 10
311 %r = getelementptr [10 x [10 x i32]], ptr %q, i64 0, i64 %a, i64 5
317 define i32 @addmuladd_gep2(ptr %p, i32 %a) {
318 ; CHECK-LABEL: addmuladd_gep2:
320 ; CHECK-NEXT: mov w8, #3240 // =0xca8
321 ; CHECK-NEXT: // kill: def $w1 killed $w1 def $x1
322 ; CHECK-NEXT: smaddl x8, w1, w8, x0
323 ; CHECK-NEXT: ldr w8, [x8, #3260]
324 ; CHECK-NEXT: tbnz w8, #31, .LBB22_2
325 ; CHECK-NEXT: // %bb.1:
326 ; CHECK-NEXT: mov w0, wzr
328 ; CHECK-NEXT: .LBB22_2: // %then
329 ; CHECK-NEXT: sxtw x8, w1
330 ; CHECK-NEXT: add x8, x8, #1
331 ; CHECK-NEXT: str x8, [x0]
332 ; CHECK-NEXT: mov w0, #1 // =0x1
334 %b = sext i32 %a to i64
335 %c = add nsw i64 %b, 1
336 %d = mul nsw i64 %c, 81
337 %g = getelementptr [10 x [10 x i32]], ptr %p, i64 0, i64 %d, i64 5
338 %l = load i32, ptr %g, align 4
339 %cc = icmp slt i32 %l, 0
340 br i1 %cc, label %then, label %else
348 define signext i32 @addmuladd_multiuse2_nsw(i32 signext %a) {
349 ; CHECK-LABEL: addmuladd_multiuse2_nsw:
351 ; CHECK-NEXT: mov w8, #324 // =0x144
352 ; CHECK-NEXT: lsl w9, w0, #2
353 ; CHECK-NEXT: mov w10, #1300 // =0x514
354 ; CHECK-NEXT: madd w8, w0, w8, w10
355 ; CHECK-NEXT: add w9, w9, #20
356 ; CHECK-NEXT: eor w0, w8, w9
358 %tmp0 = add nsw i32 %a, 4
359 %tmp1 = mul nsw i32 %tmp0, 4
360 %tmp2 = add nsw i32 %tmp1, 4
361 %tmp3 = mul nsw i32 %tmp0, 324
362 %tmp4 = add nsw i32 %tmp3, 4
363 %tmp5 = xor i32 %tmp4, %tmp2
367 define signext i32 @addmuladd_multiuse2_nuw(i32 signext %a) {
368 ; CHECK-LABEL: addmuladd_multiuse2_nuw:
370 ; CHECK-NEXT: mov w8, #324 // =0x144
371 ; CHECK-NEXT: lsl w9, w0, #2
372 ; CHECK-NEXT: mov w10, #1300 // =0x514
373 ; CHECK-NEXT: madd w8, w0, w8, w10
374 ; CHECK-NEXT: add w9, w9, #20
375 ; CHECK-NEXT: eor w0, w8, w9
377 %tmp0 = add nuw i32 %a, 4
378 %tmp1 = mul nuw i32 %tmp0, 4
379 %tmp2 = add nuw i32 %tmp1, 4
380 %tmp3 = mul nuw i32 %tmp0, 324
381 %tmp4 = add nuw i32 %tmp3, 4
382 %tmp5 = xor i32 %tmp4, %tmp2
386 define signext i32 @addmuladd_multiuse2_nswnuw(i32 signext %a) {
387 ; CHECK-LABEL: addmuladd_multiuse2_nswnuw:
389 ; CHECK-NEXT: mov w8, #324 // =0x144
390 ; CHECK-NEXT: lsl w9, w0, #2
391 ; CHECK-NEXT: mov w10, #1300 // =0x514
392 ; CHECK-NEXT: madd w8, w0, w8, w10
393 ; CHECK-NEXT: add w9, w9, #20
394 ; CHECK-NEXT: eor w0, w8, w9
396 %tmp0 = add nsw nuw i32 %a, 4
397 %tmp1 = mul nsw nuw i32 %tmp0, 4
398 %tmp2 = add nsw nuw i32 %tmp1, 4
399 %tmp3 = mul nsw nuw i32 %tmp0, 324
400 %tmp4 = add nsw nuw i32 %tmp3, 4
401 %tmp5 = xor i32 %tmp4, %tmp2