xref: /llvm-project/llvm/test/CodeGen/AArch64/immcost.ll (revision 270249de2bb3d713f89c64bf6bfbdd589c4a33fb)
1; RUN: llc -mtriple=aarch64-none-linux-gnu %s -o - -O1 -debug-only=consthoist 2>&1 | FileCheck %s
2; REQUIRES: asserts
3
4declare void @g(i64)
5
6; Single ORR.
7; CHECK:     Function: f1
8; CHECK-NOT: Collect constant
9define void @f1(i1 %cond) {
10entry:
11  call void @g(i64 -3)
12  br i1 %cond, label %true, label %ret
13
14true:
15  call void @g(i64 -3)
16  br label %ret
17
18ret:
19  ret void
20}
21
22; Constant is 0xBEEF000000000000, single MOVZ with shift.
23; CHECK:     Function: f2
24; CHECK-NOT: Collect constant
25define void @f2(i1 %cond, i64 %p, i64 %q) {
26entry:
27  %a = and i64 %p, 13758215386640154624
28  call void @g(i64 %a)
29  br i1 %cond, label %true, label %ret
30
31true:
32  %b = and i64 %q, 13758215386640154624
33  call void @g(i64 %b)
34  br label %ret
35
36ret:
37  ret void
38}
39
40; CHECK:     Function: f3
41; CHECK:     Collect constant i64 4294967103 from   %a = and i64 %p, 4294967103 with cost 2
42define void @f3(i1 %cond, i64 %p, i64 %q) {
43entry:
44  %a = and i64 %p, 4294967103
45  call void @g(i64 %a)
46  br i1 %cond, label %true, label %ret
47
48true:
49  %b = and i64 %q, 4294967103
50  call void @g(i64 %b)
51  br label %ret
52
53ret:
54  ret void
55}
56
57; CHECK:     Function: f4
58; Collect constant i64 -4688528683866062848 from   %a = and i64 %p, -4688528683866062848 with cost 2
59define void @f4(i1 %cond, i64 %p, i64 %q) {
60entry:
61  %a = and i64 %p, 13758215389843488768
62  call void @g(i64 %a)
63  br i1 %cond, label %true, label %ret
64
65true:
66  %b = and i64 %q, 13758215389843488768
67  call void @g(i64 %b)
68  br label %ret
69
70ret:
71  ret void
72}
73
74; CHECK:     Function: f5
75; Collect constant i64 88994925642865 from   %a = and i64 %p, 88994925642865 with cost 3
76define void @f5(i1 %cond, i64 %p, i64 %q) {
77entry:
78  %a = and i64 %p, 88994925642865
79  call void @g(i64 %a)
80  br i1 %cond, label %true, label %ret
81
82true:
83  %b = and i64 %q, 88994925642865
84  call void @g(i64 %b)
85  br label %ret
86
87ret:
88  ret void
89}
90
91; CHECK:     Function: f6
92; Collect constant i64 -4688439692143754127 from   %b = and i64 %q, -4688439692143754127 with cost 4
93define void @f6(i1 %cond, i64 %p, i64 %q) {
94entry:
95  %a = and i64 %p, 13758304381565797489
96  call void @g(i64 %a)
97  br i1 %cond, label %true, label %ret
98
99true:
100  %b = and i64 %q, 13758304381565797489
101  call void @g(i64 %b)
102  br label %ret
103
104ret:
105  ret void
106}
107