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 ; FIXME: Prefer movz, so it prints as "mov".
46 define i64 @test64_64_onebit() nounwind {
47 ; CHECK-LABEL: test64_64_onebit:
49 ; CHECK-NEXT: orr x0, xzr, #0x4000000000
54 ; 32-bit immed with 32-bit pattern size, rotated by 16.
55 ; FIXME: Prefer "movz" instead (so we print as "mov").
56 define i32 @test32_32_rot16() nounwind {
57 ; CHECK-LABEL: test32_32_rot16:
59 ; CHECK-NEXT: orr w0, wzr, #0xff0000
64 ; 32-bit immed with 2-bit pattern size, rotated by 1.
65 define i32 @test32_2_rot1() nounwind {
66 ; CHECK-LABEL: test32_2_rot1:
68 ; CHECK-NEXT: mov w0, #-1431655766
73 ;==--------------------------------------------------------------------------==
74 ; Tests for MOVZ with MOVK.
75 ;==--------------------------------------------------------------------------==
77 define i32 @movz() nounwind {
80 ; CHECK-NEXT: mov w0, #5
85 define i64 @movz_3movk() nounwind {
86 ; CHECK-LABEL: movz_3movk:
88 ; CHECK-NEXT: mov x0, #22136
89 ; CHECK-NEXT: movk x0, #43981, lsl #16
90 ; CHECK-NEXT: movk x0, #4660, lsl #32
91 ; CHECK-NEXT: movk x0, #5, lsl #48
93 ret i64 1427392313513592
96 define i64 @movz_movk_skip1() nounwind {
97 ; CHECK-LABEL: movz_movk_skip1:
99 ; CHECK-NEXT: mov x0, #1126236160
100 ; CHECK-NEXT: movk x0, #5, lsl #32
105 define i64 @movz_skip1_movk() nounwind {
106 ; CHECK-LABEL: movz_skip1_movk:
108 ; CHECK-NEXT: mov x0, #4660
109 ; CHECK-NEXT: movk x0, #34388, lsl #32
111 ret i64 147695335379508
114 ; FIXME: Prefer "mov w0, #2863311530; lsl x0, x0, #4"
115 ; or "mov x0, #-6148914691236517206; and x0, x0, #45812984480"
116 define i64 @orr_lsl_pattern() nounwind {
117 ; CHECK-LABEL: orr_lsl_pattern:
119 ; CHECK-NEXT: mov x0, #43680
120 ; CHECK-NEXT: movk x0, #43690, lsl #16
121 ; CHECK-NEXT: movk x0, #10, lsl #32
126 ; FIXME: prefer "mov x0, #-16639; lsl x0, x0, #24"
127 define i64 @mvn_lsl_pattern() nounwind {
128 ; CHECK-LABEL: mvn_lsl_pattern:
130 ; CHECK-NEXT: mov x0, #16777216
131 ; CHECK-NEXT: movk x0, #65471, lsl #32
132 ; CHECK-NEXT: movk x0, #65535, lsl #48
134 ret i64 -279156097024
137 ; FIXME: prefer "mov w0, #-63; movk x0, #17, lsl #32"
138 define i64 @mvn32_pattern_2() nounwind {
139 ; CHECK-LABEL: mvn32_pattern_2:
141 ; CHECK-NEXT: mov x0, #65473
142 ; CHECK-NEXT: movk x0, #65535, lsl #16
143 ; CHECK-NEXT: movk x0, #17, lsl #32
148 ;==--------------------------------------------------------------------------==
149 ; Tests for MOVN with MOVK.
150 ;==--------------------------------------------------------------------------==
152 define i64 @movn() nounwind {
155 ; CHECK-NEXT: mov x0, #-42
160 define i64 @movn_skip1_movk() nounwind {
161 ; CHECK-LABEL: movn_skip1_movk:
163 ; CHECK-NEXT: mov x0, #-60876
164 ; CHECK-NEXT: movk x0, #65494, lsl #32
166 ret i64 -176093720012
169 ;==--------------------------------------------------------------------------==
170 ; Tests for ORR with MOVK.
171 ;==--------------------------------------------------------------------------==
174 define i64 @orr_movk1() nounwind {
175 ; CHECK-LABEL: orr_movk1:
177 ; CHECK-NEXT: mov x0, #72056494543077120
178 ; CHECK-NEXT: movk x0, #57005, lsl #16
180 ret i64 72056498262245120
183 define i64 @orr_movk2() nounwind {
184 ; CHECK-LABEL: orr_movk2:
186 ; CHECK-NEXT: mov x0, #72056494543077120
187 ; CHECK-NEXT: movk x0, #57005, lsl #48
189 ret i64 -2400982650836746496
192 define i64 @orr_movk3() nounwind {
193 ; CHECK-LABEL: orr_movk3:
195 ; CHECK-NEXT: mov x0, #72056494543077120
196 ; CHECK-NEXT: movk x0, #57005, lsl #32
198 ret i64 72020953688702720
201 define i64 @orr_movk4() nounwind {
202 ; CHECK-LABEL: orr_movk4:
204 ; CHECK-NEXT: mov x0, #72056494543077120
205 ; CHECK-NEXT: movk x0, #57005
207 ret i64 72056494543068845
211 define i64 @orr_movk5() nounwind {
212 ; CHECK-LABEL: orr_movk5:
214 ; CHECK-NEXT: mov x0, #-71777214294589696
215 ; CHECK-NEXT: movk x0, #57005, lsl #16
217 ret i64 -71777214836900096
220 define i64 @orr_movk6() nounwind {
221 ; CHECK-LABEL: orr_movk6:
223 ; CHECK-NEXT: mov x0, #-71777214294589696
224 ; CHECK-NEXT: movk x0, #57005, lsl #16
225 ; CHECK-NEXT: movk x0, #57005, lsl #48
227 ret i64 -2400982647117578496
230 define i64 @orr_movk7() nounwind {
231 ; CHECK-LABEL: orr_movk7:
233 ; CHECK-NEXT: mov x0, #-71777214294589696
234 ; CHECK-NEXT: movk x0, #57005, lsl #48
236 ret i64 -2400982646575268096
239 define i64 @orr_movk8() nounwind {
240 ; CHECK-LABEL: orr_movk8:
242 ; CHECK-NEXT: mov x0, #-71777214294589696
243 ; CHECK-NEXT: movk x0, #57005
244 ; CHECK-NEXT: movk x0, #57005, lsl #48
246 ret i64 -2400982646575276371
250 define i64 @orr_movk9() nounwind {
251 ; CHECK-LABEL: orr_movk9:
253 ; CHECK-NEXT: mov x0, #1152921435887370240
254 ; CHECK-NEXT: movk x0, #65280
255 ; CHECK-NEXT: movk x0, #57005, lsl #16
257 ret i64 1152921439623315200
260 define i64 @orr_movk10() nounwind {
261 ; CHECK-LABEL: orr_movk10:
263 ; CHECK-NEXT: mov x0, #1152921504606846720
264 ; CHECK-NEXT: movk x0, #57005, lsl #16
266 ret i64 1152921504047824640
269 define i64 @orr_movk11() nounwind {
270 ; CHECK-LABEL: orr_movk11:
272 ; CHECK-NEXT: mov x0, #-65281
273 ; CHECK-NEXT: movk x0, #57005, lsl #16
274 ; CHECK-NEXT: movk x0, #65520, lsl #48
276 ret i64 -4222125209747201
279 define i64 @orr_movk12() nounwind {
280 ; CHECK-LABEL: orr_movk12:
282 ; CHECK-NEXT: mov x0, #-4503599627370241
283 ; CHECK-NEXT: movk x0, #57005, lsl #32
285 ret i64 -4258765016661761
288 define i64 @orr_movk13() nounwind {
289 ; CHECK-LABEL: orr_movk13:
291 ; CHECK-NEXT: mov x0, #17592169267200
292 ; CHECK-NEXT: movk x0, #57005
293 ; CHECK-NEXT: movk x0, #57005, lsl #48
295 ret i64 -2401245434149282131
299 define i64 @g() nounwind {
301 ; CHECK: // %bb.0: // %entry
302 ; CHECK-NEXT: mov x0, #2
303 ; CHECK-NEXT: movk x0, #65535, lsl #48
306 ret i64 -281474976710654
309 define i64 @orr_movk14() nounwind {
310 ; CHECK-LABEL: orr_movk14:
312 ; CHECK-NEXT: mov x0, #-549755813888
313 ; CHECK-NEXT: movk x0, #2048, lsl #16
315 ret i64 -549621596160
318 define i64 @orr_movk15() nounwind {
319 ; CHECK-LABEL: orr_movk15:
321 ; CHECK-NEXT: mov x0, #549755813887
322 ; CHECK-NEXT: movk x0, #63487, lsl #16
327 ; FIXME: prefer "mov x0, #2147483646; orr x0, x0, #36028659580010496"
328 define i64 @orr_movk16() nounwind {
329 ; CHECK-LABEL: orr_movk16:
331 ; CHECK-NEXT: mov x0, #36028659580010496
332 ; CHECK-NEXT: movk x0, #65534
333 ; CHECK-NEXT: movk x0, #32767, lsl #16
335 ret i64 36028661727494142
338 define i64 @orr_movk17() nounwind {
339 ; CHECK-LABEL: orr_movk17:
341 ; CHECK-NEXT: mov x0, #-1099511627776
342 ; CHECK-NEXT: movk x0, #65280, lsl #16
344 ret i64 -1095233437696
347 define i64 @orr_movk18() nounwind {
348 ; CHECK-LABEL: orr_movk18:
350 ; CHECK-NEXT: mov x0, #137438887936
351 ; CHECK-NEXT: movk x0, #65473
356 ; FIXME: prefer "mov x0, #72340172838076673; and x0, x0, #2199023255296"
357 define i64 @orr_and() nounwind {
358 ; CHECK-LABEL: orr_and:
360 ; CHECK-NEXT: mov x0, #256
361 ; CHECK-NEXT: movk x0, #257, lsl #16
362 ; CHECK-NEXT: movk x0, #257, lsl #32
364 ret i64 1103823438080
367 ; FIXME: prefer "mov w0, #-1431655766; movk x0, #9, lsl #32"
368 define i64 @movn_movk() nounwind {
369 ; CHECK-LABEL: movn_movk:
371 ; CHECK-NEXT: mov x0, #43690
372 ; CHECK-NEXT: movk x0, #43690, lsl #16
373 ; CHECK-NEXT: movk x0, #9, lsl #32
378 ; FIXME: prefer "mov w0, #-13690; orr x0, x0, #0x1111111111111111"
379 define i64 @movn_orr() nounwind {
380 ; CHECK-LABEL: movn_orr:
382 ; CHECK-NEXT: mov x0, #-51847
383 ; CHECK-NEXT: movk x0, #4369, lsl #32
384 ; CHECK-NEXT: movk x0, #4369, lsl #48
386 ret i64 1229782942255887737
389 ; FIXME: prefer "mov w0, #-305397761; eor x0, x0, #0x3333333333333333"
390 define i64 @movn_eor() nounwind {
391 ; CHECK-LABEL: movn_eor:
393 ; CHECK-NEXT: mov x0, #3689348814741910323
394 ; CHECK-NEXT: movk x0, #52428
395 ; CHECK-NEXT: movk x0, #8455, lsl #16
397 ret i64 3689348814437076172
400 ; FIXME: prefer "mov x0, #536866816; orr x0, x0, #0x3fff800000000000"
401 define i64 @orr_orr_64() nounwind {
402 ; CHECK-LABEL: orr_orr_64:
404 ; CHECK-NEXT: mov x0, #4611545280939032576
405 ; CHECK-NEXT: movk x0, #61440
406 ; CHECK-NEXT: movk x0, #8191, lsl #16
408 ret i64 4611545281475899392
411 ; FIXME: prefer "mov x0, #558551907040256; orr x0, x0, #0x1000100010001000"
412 define i64 @orr_orr_32() nounwind {
413 ; CHECK-LABEL: orr_orr_32:
415 ; CHECK-NEXT: mov x0, #-287953294993589248
416 ; CHECK-NEXT: movk x0, #7169, lsl #16
417 ; CHECK-NEXT: movk x0, #7169, lsl #48
419 ret i64 2018171185438784512
422 ; FIXME: prefer "mov x0, #281479271743489; orr x0, x0, #0x1000100010001000"
423 define i64 @orr_orr_16() nounwind {
424 ; CHECK-LABEL: orr_orr_16:
426 ; CHECK-NEXT: mov x0, #4097
427 ; CHECK-NEXT: movk x0, #4097, lsl #16
428 ; CHECK-NEXT: movk x0, #4097, lsl #32
429 ; CHECK-NEXT: movk x0, #4097, lsl #48
431 ret i64 1153220576333074433
434 ; FIXME: prefer "mov x0, #144680345676153346; orr x0, x0, #0x1818181818181818"
435 define i64 @orr_orr_8() nounwind {
436 ; CHECK-LABEL: orr_orr_8:
438 ; CHECK-NEXT: mov x0, #6682
439 ; CHECK-NEXT: movk x0, #6682, lsl #16
440 ; CHECK-NEXT: movk x0, #6682, lsl #32
441 ; CHECK-NEXT: movk x0, #6682, lsl #48
443 ret i64 1880844493789993498
446 ; FIXME: prefer "mov x0, #-6148914691236517206; orr x0, x0, #0x0FFFFF0000000000"
447 define i64 @orr_64_orr_8() nounwind {
448 ; CHECK-LABEL: orr_64_orr_8:
450 ; CHECK-NEXT: mov x0, #-6148914691236517206
451 ; CHECK-NEXT: movk x0, #65450, lsl #32
452 ; CHECK-NEXT: movk x0, #45055, lsl #48
454 ret i64 -5764607889538110806