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 define i64 @orr_lsl_pattern() nounwind {
113 ; CHECK-LABEL: orr_lsl_pattern:
115 ; CHECK-NEXT: mov x0, #-6148914691236517206
116 ; CHECK-NEXT: and x0, x0, #0x1fffffffe0
121 ; FIXME: prefer "mov x0, #-16639; lsl x0, x0, #24"
122 define i64 @mvn_lsl_pattern() nounwind {
123 ; CHECK-LABEL: mvn_lsl_pattern:
125 ; CHECK-NEXT: mov x0, #16777216
126 ; CHECK-NEXT: movk x0, #65471, lsl #32
127 ; CHECK-NEXT: movk x0, #65535, lsl #48
129 ret i64 -279156097024
132 ; FIXME: prefer "mov w0, #-63; movk x0, #17, lsl #32"
133 define i64 @mvn32_pattern_2() nounwind {
134 ; CHECK-LABEL: mvn32_pattern_2:
136 ; CHECK-NEXT: mov x0, #65473
137 ; CHECK-NEXT: movk x0, #65535, lsl #16
138 ; CHECK-NEXT: movk x0, #17, lsl #32
143 ;==--------------------------------------------------------------------------==
144 ; Tests for MOVN with MOVK.
145 ;==--------------------------------------------------------------------------==
147 define i64 @movn() nounwind {
150 ; CHECK-NEXT: mov x0, #-42
155 define i64 @movn_skip1_movk() nounwind {
156 ; CHECK-LABEL: movn_skip1_movk:
158 ; CHECK-NEXT: mov x0, #-60876
159 ; CHECK-NEXT: movk x0, #65494, lsl #32
161 ret i64 -176093720012
164 ;==--------------------------------------------------------------------------==
165 ; Tests for ORR with MOVK.
166 ;==--------------------------------------------------------------------------==
169 define i64 @orr_movk1() nounwind {
170 ; CHECK-LABEL: orr_movk1:
172 ; CHECK-NEXT: mov x0, #72056494543077120
173 ; CHECK-NEXT: movk x0, #57005, lsl #16
175 ret i64 72056498262245120
178 define i64 @orr_movk2() nounwind {
179 ; CHECK-LABEL: orr_movk2:
181 ; CHECK-NEXT: mov x0, #72056494543077120
182 ; CHECK-NEXT: movk x0, #57005, lsl #48
184 ret i64 -2400982650836746496
187 define i64 @orr_movk3() nounwind {
188 ; CHECK-LABEL: orr_movk3:
190 ; CHECK-NEXT: mov x0, #72056494543077120
191 ; CHECK-NEXT: movk x0, #57005, lsl #32
193 ret i64 72020953688702720
196 define i64 @orr_movk4() nounwind {
197 ; CHECK-LABEL: orr_movk4:
199 ; CHECK-NEXT: mov x0, #72056494543077120
200 ; CHECK-NEXT: movk x0, #57005
202 ret i64 72056494543068845
206 define i64 @orr_movk5() nounwind {
207 ; CHECK-LABEL: orr_movk5:
209 ; CHECK-NEXT: mov x0, #-71777214294589696
210 ; CHECK-NEXT: movk x0, #57005, lsl #16
212 ret i64 -71777214836900096
215 define i64 @orr_movk6() nounwind {
216 ; CHECK-LABEL: orr_movk6:
218 ; CHECK-NEXT: mov x0, #-71777214294589696
219 ; CHECK-NEXT: movk x0, #57005, lsl #16
220 ; CHECK-NEXT: movk x0, #57005, lsl #48
222 ret i64 -2400982647117578496
225 define i64 @orr_movk7() nounwind {
226 ; CHECK-LABEL: orr_movk7:
228 ; CHECK-NEXT: mov x0, #-71777214294589696
229 ; CHECK-NEXT: movk x0, #57005, lsl #48
231 ret i64 -2400982646575268096
234 define i64 @orr_movk8() nounwind {
235 ; CHECK-LABEL: orr_movk8:
237 ; CHECK-NEXT: mov x0, #-71777214294589696
238 ; CHECK-NEXT: movk x0, #57005
239 ; CHECK-NEXT: movk x0, #57005, lsl #48
241 ret i64 -2400982646575276371
245 define i64 @orr_movk9() nounwind {
246 ; CHECK-LABEL: orr_movk9:
248 ; CHECK-NEXT: mov x0, #1152921435887370240
249 ; CHECK-NEXT: movk x0, #65280
250 ; CHECK-NEXT: movk x0, #57005, lsl #16
252 ret i64 1152921439623315200
255 define i64 @orr_movk10() nounwind {
256 ; CHECK-LABEL: orr_movk10:
258 ; CHECK-NEXT: mov x0, #1152921504606846720
259 ; CHECK-NEXT: movk x0, #57005, lsl #16
261 ret i64 1152921504047824640
264 define i64 @orr_movk11() nounwind {
265 ; CHECK-LABEL: orr_movk11:
267 ; CHECK-NEXT: mov x0, #-65281
268 ; CHECK-NEXT: movk x0, #57005, lsl #16
269 ; CHECK-NEXT: movk x0, #65520, lsl #48
271 ret i64 -4222125209747201
274 define i64 @orr_movk12() nounwind {
275 ; CHECK-LABEL: orr_movk12:
277 ; CHECK-NEXT: mov x0, #-4503599627370241
278 ; CHECK-NEXT: movk x0, #57005, lsl #32
280 ret i64 -4258765016661761
283 define i64 @orr_movk13() nounwind {
284 ; CHECK-LABEL: orr_movk13:
286 ; CHECK-NEXT: mov x0, #17592169267200
287 ; CHECK-NEXT: movk x0, #57005
288 ; CHECK-NEXT: movk x0, #57005, lsl #48
290 ret i64 -2401245434149282131
294 define i64 @g() nounwind {
296 ; CHECK: // %bb.0: // %entry
297 ; CHECK-NEXT: mov x0, #2
298 ; CHECK-NEXT: movk x0, #65535, lsl #48
301 ret i64 -281474976710654
304 define i64 @orr_movk14() nounwind {
305 ; CHECK-LABEL: orr_movk14:
307 ; CHECK-NEXT: mov x0, #-549755813888
308 ; CHECK-NEXT: movk x0, #2048, lsl #16
310 ret i64 -549621596160
313 define i64 @orr_movk15() nounwind {
314 ; CHECK-LABEL: orr_movk15:
316 ; CHECK-NEXT: mov x0, #549755813887
317 ; CHECK-NEXT: movk x0, #63487, lsl #16
322 define i64 @orr_movk16() nounwind {
323 ; CHECK-LABEL: orr_movk16:
325 ; CHECK-NEXT: mov x0, #2147483646
326 ; CHECK-NEXT: orr x0, x0, #0x7fffe0007fffe0
328 ret i64 36028661727494142
331 define i64 @orr_movk17() nounwind {
332 ; CHECK-LABEL: orr_movk17:
334 ; CHECK-NEXT: mov x0, #-1099511627776
335 ; CHECK-NEXT: movk x0, #65280, lsl #16
337 ret i64 -1095233437696
340 define i64 @orr_movk18() nounwind {
341 ; CHECK-LABEL: orr_movk18:
343 ; CHECK-NEXT: mov x0, #137438887936
344 ; CHECK-NEXT: movk x0, #65473
349 define i64 @orr_and() nounwind {
350 ; CHECK-LABEL: orr_and:
352 ; CHECK-NEXT: mov x0, #72340172838076673
353 ; CHECK-NEXT: and x0, x0, #0xffffffffff00
355 ret i64 1103823438080
358 ; FIXME: prefer "mov w0, #-1431655766; movk x0, #9, lsl #32"
359 define i64 @movn_movk() nounwind {
360 ; CHECK-LABEL: movn_movk:
362 ; CHECK-NEXT: mov x0, #43690
363 ; CHECK-NEXT: movk x0, #43690, lsl #16
364 ; CHECK-NEXT: movk x0, #9, lsl #32
369 ; FIXME: prefer "mov w0, #-13690; orr x0, x0, #0x1111111111111111"
370 define i64 @movn_orr() nounwind {
371 ; CHECK-LABEL: movn_orr:
373 ; CHECK-NEXT: mov x0, #-51847
374 ; CHECK-NEXT: movk x0, #4369, lsl #32
375 ; CHECK-NEXT: movk x0, #4369, lsl #48
377 ret i64 1229782942255887737
380 ; FIXME: prefer "mov w0, #-305397761; eor x0, x0, #0x3333333333333333"
381 define i64 @movn_eor() nounwind {
382 ; CHECK-LABEL: movn_eor:
384 ; CHECK-NEXT: mov x0, #3689348814741910323
385 ; CHECK-NEXT: movk x0, #52428
386 ; CHECK-NEXT: movk x0, #8455, lsl #16
388 ret i64 3689348814437076172
391 define i64 @orr_orr_64() nounwind {
392 ; CHECK-LABEL: orr_orr_64:
394 ; CHECK-NEXT: mov x0, #536866816
395 ; CHECK-NEXT: orr x0, x0, #0x3fff800000000000
397 ret i64 4611545281475899392
400 define i64 @orr_orr_32() nounwind {
401 ; CHECK-LABEL: orr_orr_32:
403 ; CHECK-NEXT: mov x0, #558551907040256
404 ; CHECK-NEXT: orr x0, x0, #0x1c001c001c001c00
406 ret i64 2018171185438784512
409 define i64 @orr_orr_16() nounwind {
410 ; CHECK-LABEL: orr_orr_16:
412 ; CHECK-NEXT: mov x0, #1152939097061330944
413 ; CHECK-NEXT: orr x0, x0, #0x1000100010001
415 ret i64 1153220576333074433
418 define i64 @orr_orr_8() nounwind {
419 ; CHECK-LABEL: orr_orr_8:
421 ; CHECK-NEXT: mov x0, #144680345676153346
422 ; CHECK-NEXT: orr x0, x0, #0x1818181818181818
424 ret i64 1880844493789993498
427 define i64 @orr_64_orr_8() nounwind {
428 ; CHECK-LABEL: orr_64_orr_8:
430 ; CHECK-NEXT: mov x0, #-6148914691236517206
431 ; CHECK-NEXT: orr x0, x0, #0xfffff0000000000
433 ret i64 -5764607889538110806