xref: /aosp_15_r20/external/llvm/test/CodeGen/AArch64/movw-consts.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -verify-machineinstrs -o - %s -mtriple=arm64-apple-ios7.0 | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Workerdefine i64 @test0() {
4*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test0:
5*9880d681SAndroid Build Coastguard Worker; Not produced by move wide instructions, but good to make sure we can return 0 anyway:
6*9880d681SAndroid Build Coastguard Worker; CHECK: mov x0, xzr
7*9880d681SAndroid Build Coastguard Worker  ret i64 0
8*9880d681SAndroid Build Coastguard Worker}
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Workerdefine i64 @test1() {
11*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test1:
12*9880d681SAndroid Build Coastguard Worker; CHECK: orr w0, wzr, #0x1
13*9880d681SAndroid Build Coastguard Worker  ret i64 1
14*9880d681SAndroid Build Coastguard Worker}
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard Workerdefine i64 @test2() {
17*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test2:
18*9880d681SAndroid Build Coastguard Worker; CHECK: orr w0, wzr, #0xffff
19*9880d681SAndroid Build Coastguard Worker  ret i64 65535
20*9880d681SAndroid Build Coastguard Worker}
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Workerdefine i64 @test3() {
23*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test3:
24*9880d681SAndroid Build Coastguard Worker; CHECK: orr w0, wzr, #0x10000
25*9880d681SAndroid Build Coastguard Worker  ret i64 65536
26*9880d681SAndroid Build Coastguard Worker}
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Workerdefine i64 @test4() {
29*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test4:
30*9880d681SAndroid Build Coastguard Worker; CHECK: orr w0, wzr, #0xffff0000
31*9880d681SAndroid Build Coastguard Worker  ret i64 4294901760
32*9880d681SAndroid Build Coastguard Worker}
33*9880d681SAndroid Build Coastguard Worker
34*9880d681SAndroid Build Coastguard Workerdefine i64 @test5() {
35*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test5:
36*9880d681SAndroid Build Coastguard Worker; CHECK: orr x0, xzr, #0x100000000
37*9880d681SAndroid Build Coastguard Worker  ret i64 4294967296
38*9880d681SAndroid Build Coastguard Worker}
39*9880d681SAndroid Build Coastguard Worker
40*9880d681SAndroid Build Coastguard Workerdefine i64 @test6() {
41*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test6:
42*9880d681SAndroid Build Coastguard Worker; CHECK: orr x0, xzr, #0xffff00000000
43*9880d681SAndroid Build Coastguard Worker  ret i64 281470681743360
44*9880d681SAndroid Build Coastguard Worker}
45*9880d681SAndroid Build Coastguard Worker
46*9880d681SAndroid Build Coastguard Workerdefine i64 @test7() {
47*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test7:
48*9880d681SAndroid Build Coastguard Worker; CHECK: orr x0, xzr, #0x1000000000000
49*9880d681SAndroid Build Coastguard Worker  ret i64 281474976710656
50*9880d681SAndroid Build Coastguard Worker}
51*9880d681SAndroid Build Coastguard Worker
52*9880d681SAndroid Build Coastguard Worker; A 32-bit MOVN can generate some 64-bit patterns that a 64-bit one
53*9880d681SAndroid Build Coastguard Worker; couldn't. Useful even for i64
54*9880d681SAndroid Build Coastguard Workerdefine i64 @test8() {
55*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test8:
56*9880d681SAndroid Build Coastguard Worker; CHECK: mov w0, #-60876
57*9880d681SAndroid Build Coastguard Worker  ret i64 4294906420
58*9880d681SAndroid Build Coastguard Worker}
59*9880d681SAndroid Build Coastguard Worker
60*9880d681SAndroid Build Coastguard Workerdefine i64 @test9() {
61*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test9:
62*9880d681SAndroid Build Coastguard Worker; CHECK: mov x0, #-1
63*9880d681SAndroid Build Coastguard Worker  ret i64 -1
64*9880d681SAndroid Build Coastguard Worker}
65*9880d681SAndroid Build Coastguard Worker
66*9880d681SAndroid Build Coastguard Workerdefine i64 @test10() {
67*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test10:
68*9880d681SAndroid Build Coastguard Worker; CHECK: mov x0, #-3989504001
69*9880d681SAndroid Build Coastguard Worker  ret i64 18446744069720047615
70*9880d681SAndroid Build Coastguard Worker}
71*9880d681SAndroid Build Coastguard Worker
72*9880d681SAndroid Build Coastguard Worker; For reasonably legitimate reasons returning an i32 results in the
73*9880d681SAndroid Build Coastguard Worker; selection of an i64 constant, so we need a different idiom to test that selection
74*9880d681SAndroid Build Coastguard Worker@var32 = global i32 0
75*9880d681SAndroid Build Coastguard Worker
76*9880d681SAndroid Build Coastguard Workerdefine void @test11() {
77*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test11:
78*9880d681SAndroid Build Coastguard Worker; CHECK: str wzr
79*9880d681SAndroid Build Coastguard Worker  store i32 0, i32* @var32
80*9880d681SAndroid Build Coastguard Worker  ret void
81*9880d681SAndroid Build Coastguard Worker}
82*9880d681SAndroid Build Coastguard Worker
83*9880d681SAndroid Build Coastguard Workerdefine void @test12() {
84*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test12:
85*9880d681SAndroid Build Coastguard Worker; CHECK: orr {{w[0-9]+}}, wzr, #0x1
86*9880d681SAndroid Build Coastguard Worker  store i32 1, i32* @var32
87*9880d681SAndroid Build Coastguard Worker  ret void
88*9880d681SAndroid Build Coastguard Worker}
89*9880d681SAndroid Build Coastguard Worker
90*9880d681SAndroid Build Coastguard Workerdefine void @test13() {
91*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test13:
92*9880d681SAndroid Build Coastguard Worker; CHECK: orr {{w[0-9]+}}, wzr, #0xffff
93*9880d681SAndroid Build Coastguard Worker  store i32 65535, i32* @var32
94*9880d681SAndroid Build Coastguard Worker  ret void
95*9880d681SAndroid Build Coastguard Worker}
96*9880d681SAndroid Build Coastguard Worker
97*9880d681SAndroid Build Coastguard Workerdefine void @test14() {
98*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test14:
99*9880d681SAndroid Build Coastguard Worker; CHECK: orr {{w[0-9]+}}, wzr, #0x10000
100*9880d681SAndroid Build Coastguard Worker  store i32 65536, i32* @var32
101*9880d681SAndroid Build Coastguard Worker  ret void
102*9880d681SAndroid Build Coastguard Worker}
103*9880d681SAndroid Build Coastguard Worker
104*9880d681SAndroid Build Coastguard Workerdefine void @test15() {
105*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test15:
106*9880d681SAndroid Build Coastguard Worker; CHECK: orr {{w[0-9]+}}, wzr, #0xffff0000
107*9880d681SAndroid Build Coastguard Worker  store i32 4294901760, i32* @var32
108*9880d681SAndroid Build Coastguard Worker  ret void
109*9880d681SAndroid Build Coastguard Worker}
110*9880d681SAndroid Build Coastguard Worker
111*9880d681SAndroid Build Coastguard Workerdefine void @test16() {
112*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test16:
113*9880d681SAndroid Build Coastguard Worker; CHECK: mov {{w[0-9]+}}, #-1
114*9880d681SAndroid Build Coastguard Worker  store i32 -1, i32* @var32
115*9880d681SAndroid Build Coastguard Worker  ret void
116*9880d681SAndroid Build Coastguard Worker}
117*9880d681SAndroid Build Coastguard Worker
118*9880d681SAndroid Build Coastguard Workerdefine i64 @test17() {
119*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test17:
120*9880d681SAndroid Build Coastguard Worker
121*9880d681SAndroid Build Coastguard Worker  ; Mustn't MOVN w0 here.
122*9880d681SAndroid Build Coastguard Worker; CHECK: orr x0, xzr, #0xfffffffffffffffd
123*9880d681SAndroid Build Coastguard Worker  ret i64 -3
124*9880d681SAndroid Build Coastguard Worker}
125