1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=aarch64-eabi | FileCheck %s
4 ;==--------------------------------------------------------------------------==
5 ; Tests for MOV-immediate implemented with ORR-immediate.
6 ;==--------------------------------------------------------------------------==
8 ; 64-bit immed with 32-bit pattern size, rotated by 0.
9 define i64 @test64_32_rot0() nounwind {
10 ; CHECK-LABEL: test64_32_rot0:
12 ; CHECK-NEXT: mov x0, #30064771079
17 ; 64-bit immed with 32-bit pattern size, rotated by 2.
18 define i64 @test64_32_rot2() nounwind {
19 ; CHECK-LABEL: test64_32_rot2:
21 ; CHECK-NEXT: mov x0, #-4611686002321260541
23 ret i64 13835058071388291075
26 ; 64-bit immed with 4-bit pattern size, rotated by 3.
27 define i64 @test64_4_rot3() nounwind {
28 ; CHECK-LABEL: test64_4_rot3:
30 ; CHECK-NEXT: mov x0, #-1229782938247303442
32 ret i64 17216961135462248174
35 ; 64-bit immed with 64-bit pattern size, many bits.
36 define i64 @test64_64_manybits() nounwind {
37 ; CHECK-LABEL: test64_64_manybits:
39 ; CHECK-NEXT: mov x0, #4503599627304960
41 ret i64 4503599627304960
44 ; 64-bit immed with 64-bit pattern size, one bit.
45 define i64 @test64_64_onebit() nounwind {
46 ; CHECK-LABEL: test64_64_onebit:
48 ; CHECK-NEXT: mov x0, #274877906944
53 ; 32-bit immed with 32-bit pattern size, rotated by 16.
54 define i32 @test32_32_rot16() nounwind {
55 ; CHECK-LABEL: test32_32_rot16:
57 ; CHECK-NEXT: mov w0, #16711680
62 ; 32-bit immed with 2-bit pattern size, rotated by 1.
63 define i32 @test32_2_rot1() nounwind {
64 ; CHECK-LABEL: test32_2_rot1:
66 ; CHECK-NEXT: mov w0, #-1431655766
71 ;==--------------------------------------------------------------------------==
72 ; Tests for MOVZ with MOVK.
73 ;==--------------------------------------------------------------------------==
75 define i32 @movz() nounwind {
78 ; CHECK-NEXT: mov w0, #5
83 define i64 @movz_3movk() nounwind {
84 ; CHECK-LABEL: movz_3movk:
86 ; CHECK-NEXT: mov x0, #22136
87 ; CHECK-NEXT: movk x0, #43981, lsl #16
88 ; CHECK-NEXT: movk x0, #4660, lsl #32
89 ; CHECK-NEXT: movk x0, #5, lsl #48
91 ret i64 1427392313513592
94 define i64 @movz_movk_skip1() nounwind {
95 ; CHECK-LABEL: movz_movk_skip1:
97 ; CHECK-NEXT: mov x0, #1126236160
98 ; CHECK-NEXT: movk x0, #5, lsl #32
103 define i64 @movz_skip1_movk() nounwind {
104 ; CHECK-LABEL: movz_skip1_movk:
106 ; CHECK-NEXT: mov x0, #4660
107 ; CHECK-NEXT: movk x0, #34388, lsl #32
109 ret i64 147695335379508
112 ; FIXME: Prefer "mov w0, #2863311530; lsl x0, x0, #4"
113 ; or "mov x0, #-6148914691236517206; and x0, x0, #45812984480"
114 define i64 @orr_lsl_pattern() nounwind {
115 ; CHECK-LABEL: orr_lsl_pattern:
117 ; CHECK-NEXT: mov x0, #43680
118 ; CHECK-NEXT: movk x0, #43690, lsl #16
119 ; CHECK-NEXT: movk x0, #10, lsl #32
124 ; FIXME: prefer "mov x0, #-16639; lsl x0, x0, #24"
125 define i64 @mvn_lsl_pattern() nounwind {
126 ; CHECK-LABEL: mvn_lsl_pattern:
128 ; CHECK-NEXT: mov x0, #16777216
129 ; CHECK-NEXT: movk x0, #65471, lsl #32
130 ; CHECK-NEXT: movk x0, #65535, lsl #48
132 ret i64 -279156097024
135 ; FIXME: prefer "mov w0, #-63; movk x0, #17, lsl #32"
136 define i64 @mvn32_pattern_2() nounwind {
137 ; CHECK-LABEL: mvn32_pattern_2:
139 ; CHECK-NEXT: mov x0, #65473
140 ; CHECK-NEXT: movk x0, #65535, lsl #16
141 ; CHECK-NEXT: movk x0, #17, lsl #32
146 ;==--------------------------------------------------------------------------==
147 ; Tests for MOVN with MOVK.
148 ;==--------------------------------------------------------------------------==
150 define i64 @movn() nounwind {
153 ; CHECK-NEXT: mov x0, #-42
158 define i64 @movn_skip1_movk() nounwind {
159 ; CHECK-LABEL: movn_skip1_movk:
161 ; CHECK-NEXT: mov x0, #-60876
162 ; CHECK-NEXT: movk x0, #65494, lsl #32
164 ret i64 -176093720012
167 ;==--------------------------------------------------------------------------==
168 ; Tests for ORR with MOVK.
169 ;==--------------------------------------------------------------------------==
172 define i64 @orr_movk1() nounwind {
173 ; CHECK-LABEL: orr_movk1:
175 ; CHECK-NEXT: mov x0, #72056494543077120
176 ; CHECK-NEXT: movk x0, #57005, lsl #16
178 ret i64 72056498262245120
181 define i64 @orr_movk2() nounwind {
182 ; CHECK-LABEL: orr_movk2:
184 ; CHECK-NEXT: mov x0, #72056494543077120
185 ; CHECK-NEXT: movk x0, #57005, lsl #48
187 ret i64 -2400982650836746496
190 define i64 @orr_movk3() nounwind {
191 ; CHECK-LABEL: orr_movk3:
193 ; CHECK-NEXT: mov x0, #72056494543077120
194 ; CHECK-NEXT: movk x0, #57005, lsl #32
196 ret i64 72020953688702720
199 define i64 @orr_movk4() nounwind {
200 ; CHECK-LABEL: orr_movk4:
202 ; CHECK-NEXT: mov x0, #72056494543077120
203 ; CHECK-NEXT: movk x0, #57005
205 ret i64 72056494543068845
209 define i64 @orr_movk5() nounwind {
210 ; CHECK-LABEL: orr_movk5:
212 ; CHECK-NEXT: mov x0, #-71777214294589696
213 ; CHECK-NEXT: movk x0, #57005, lsl #16
215 ret i64 -71777214836900096
218 define i64 @orr_movk6() nounwind {
219 ; CHECK-LABEL: orr_movk6:
221 ; CHECK-NEXT: mov x0, #-71777214294589696
222 ; CHECK-NEXT: movk x0, #57005, lsl #16
223 ; CHECK-NEXT: movk x0, #57005, lsl #48
225 ret i64 -2400982647117578496
228 define i64 @orr_movk7() nounwind {
229 ; CHECK-LABEL: orr_movk7:
231 ; CHECK-NEXT: mov x0, #-71777214294589696
232 ; CHECK-NEXT: movk x0, #57005, lsl #48
234 ret i64 -2400982646575268096
237 define i64 @orr_movk8() nounwind {
238 ; CHECK-LABEL: orr_movk8:
240 ; CHECK-NEXT: mov x0, #-71777214294589696
241 ; CHECK-NEXT: movk x0, #57005
242 ; CHECK-NEXT: movk x0, #57005, lsl #48
244 ret i64 -2400982646575276371
248 define i64 @orr_movk9() nounwind {
249 ; CHECK-LABEL: orr_movk9:
251 ; CHECK-NEXT: mov x0, #1152921435887370240
252 ; CHECK-NEXT: movk x0, #65280
253 ; CHECK-NEXT: movk x0, #57005, lsl #16
255 ret i64 1152921439623315200
258 define i64 @orr_movk10() nounwind {
259 ; CHECK-LABEL: orr_movk10:
261 ; CHECK-NEXT: mov x0, #1152921504606846720
262 ; CHECK-NEXT: movk x0, #57005, lsl #16
264 ret i64 1152921504047824640
267 define i64 @orr_movk11() nounwind {
268 ; CHECK-LABEL: orr_movk11:
270 ; CHECK-NEXT: mov x0, #-65281
271 ; CHECK-NEXT: movk x0, #57005, lsl #16
272 ; CHECK-NEXT: movk x0, #65520, lsl #48
274 ret i64 -4222125209747201
277 define i64 @orr_movk12() nounwind {
278 ; CHECK-LABEL: orr_movk12:
280 ; CHECK-NEXT: mov x0, #-4503599627370241
281 ; CHECK-NEXT: movk x0, #57005, lsl #32
283 ret i64 -4258765016661761
286 define i64 @orr_movk13() nounwind {
287 ; CHECK-LABEL: orr_movk13:
289 ; CHECK-NEXT: mov x0, #17592169267200
290 ; CHECK-NEXT: movk x0, #57005
291 ; CHECK-NEXT: movk x0, #57005, lsl #48
293 ret i64 -2401245434149282131
297 define i64 @g() nounwind {
299 ; CHECK: // %bb.0: // %entry
300 ; CHECK-NEXT: mov x0, #2
301 ; CHECK-NEXT: movk x0, #65535, lsl #48
304 ret i64 -281474976710654
307 define i64 @orr_movk14() nounwind {
308 ; CHECK-LABEL: orr_movk14:
310 ; CHECK-NEXT: mov x0, #-549755813888
311 ; CHECK-NEXT: movk x0, #2048, lsl #16
313 ret i64 -549621596160
316 define i64 @orr_movk15() nounwind {
317 ; CHECK-LABEL: orr_movk15:
319 ; CHECK-NEXT: mov x0, #549755813887
320 ; CHECK-NEXT: movk x0, #63487, lsl #16
325 ; FIXME: prefer "mov x0, #2147483646; orr x0, x0, #36028659580010496"
326 define i64 @orr_movk16() nounwind {
327 ; CHECK-LABEL: orr_movk16:
329 ; CHECK-NEXT: mov x0, #36028659580010496
330 ; CHECK-NEXT: movk x0, #65534
331 ; CHECK-NEXT: movk x0, #32767, lsl #16
333 ret i64 36028661727494142
336 define i64 @orr_movk17() nounwind {
337 ; CHECK-LABEL: orr_movk17:
339 ; CHECK-NEXT: mov x0, #-1099511627776
340 ; CHECK-NEXT: movk x0, #65280, lsl #16
342 ret i64 -1095233437696
345 define i64 @orr_movk18() nounwind {
346 ; CHECK-LABEL: orr_movk18:
348 ; CHECK-NEXT: mov x0, #137438887936
349 ; CHECK-NEXT: movk x0, #65473
354 ; FIXME: prefer "mov x0, #72340172838076673; and x0, x0, #2199023255296"
355 define i64 @orr_and() nounwind {
356 ; CHECK-LABEL: orr_and:
358 ; CHECK-NEXT: mov x0, #256
359 ; CHECK-NEXT: movk x0, #257, lsl #16
360 ; CHECK-NEXT: movk x0, #257, lsl #32
362 ret i64 1103823438080
365 ; FIXME: prefer "mov w0, #-1431655766; movk x0, #9, lsl #32"
366 define i64 @movn_movk() nounwind {
367 ; CHECK-LABEL: movn_movk:
369 ; CHECK-NEXT: mov x0, #43690
370 ; CHECK-NEXT: movk x0, #43690, lsl #16
371 ; CHECK-NEXT: movk x0, #9, lsl #32
376 ; FIXME: prefer "mov w0, #-13690; orr x0, x0, #0x1111111111111111"
377 define i64 @movn_orr() nounwind {
378 ; CHECK-LABEL: movn_orr:
380 ; CHECK-NEXT: mov x0, #-51847
381 ; CHECK-NEXT: movk x0, #4369, lsl #32
382 ; CHECK-NEXT: movk x0, #4369, lsl #48
384 ret i64 1229782942255887737
387 ; FIXME: prefer "mov w0, #-305397761; eor x0, x0, #0x3333333333333333"
388 define i64 @movn_eor() nounwind {
389 ; CHECK-LABEL: movn_eor:
391 ; CHECK-NEXT: mov x0, #3689348814741910323
392 ; CHECK-NEXT: movk x0, #52428
393 ; CHECK-NEXT: movk x0, #8455, lsl #16
395 ret i64 3689348814437076172
398 ; FIXME: prefer "mov x0, #536866816; orr x0, x0, #0x3fff800000000000"
399 define i64 @orr_orr_64() nounwind {
400 ; CHECK-LABEL: orr_orr_64:
402 ; CHECK-NEXT: mov x0, #4611545280939032576
403 ; CHECK-NEXT: movk x0, #61440
404 ; CHECK-NEXT: movk x0, #8191, lsl #16
406 ret i64 4611545281475899392
409 ; FIXME: prefer "mov x0, #558551907040256; orr x0, x0, #0x1000100010001000"
410 define i64 @orr_orr_32() nounwind {
411 ; CHECK-LABEL: orr_orr_32:
413 ; CHECK-NEXT: mov x0, #-287953294993589248
414 ; CHECK-NEXT: movk x0, #7169, lsl #16
415 ; CHECK-NEXT: movk x0, #7169, lsl #48
417 ret i64 2018171185438784512
420 ; FIXME: prefer "mov x0, #281479271743489; orr x0, x0, #0x1000100010001000"
421 define i64 @orr_orr_16() nounwind {
422 ; CHECK-LABEL: orr_orr_16:
424 ; CHECK-NEXT: mov x0, #4097
425 ; CHECK-NEXT: movk x0, #4097, lsl #16
426 ; CHECK-NEXT: movk x0, #4097, lsl #32
427 ; CHECK-NEXT: movk x0, #4097, lsl #48
429 ret i64 1153220576333074433
432 ; FIXME: prefer "mov x0, #144680345676153346; orr x0, x0, #0x1818181818181818"
433 define i64 @orr_orr_8() nounwind {
434 ; CHECK-LABEL: orr_orr_8:
436 ; CHECK-NEXT: mov x0, #6682
437 ; CHECK-NEXT: movk x0, #6682, lsl #16
438 ; CHECK-NEXT: movk x0, #6682, lsl #32
439 ; CHECK-NEXT: movk x0, #6682, lsl #48
441 ret i64 1880844493789993498
444 ; FIXME: prefer "mov x0, #-6148914691236517206; orr x0, x0, #0x0FFFFF0000000000"
445 define i64 @orr_64_orr_8() nounwind {
446 ; CHECK-LABEL: orr_64_orr_8:
448 ; CHECK-NEXT: mov x0, #-6148914691236517206
449 ; CHECK-NEXT: movk x0, #65450, lsl #32
450 ; CHECK-NEXT: movk x0, #45055, lsl #48
452 ret i64 -5764607889538110806