1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2; RUN: opt < %s -mtriple=aarch64 -cost-model -analyze | FileCheck %s
3
4; Verify the cost of scalar ctlz instructions.
5
6define i64 @test_cttz_i64(i64 %a) {
7;
8; CHECK-LABEL: 'test_cttz_i64'
9; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %cttz = call i64 @llvm.cttz.i64(i64 %a, i1 false)
10; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i64 %cttz
11;
12  %cttz = call i64 @llvm.cttz.i64(i64 %a)
13  ret i64 %cttz
14}
15
16define i32 @test_cttz_i32(i32 %a) {
17;
18; CHECK-LABEL: 'test_cttz_i32'
19; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %cttz = call i32 @llvm.cttz.i32(i32 %a, i1 false)
20; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i32 %cttz
21;
22  %cttz = call i32 @llvm.cttz.i32(i32 %a)
23  ret i32 %cttz
24}
25
26define i16 @test_cttz_i16(i16 %a) {
27;
28; CHECK-LABEL: 'test_cttz_i16'
29; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %cttz = call i16 @llvm.cttz.i16(i16 %a, i1 false)
30; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i16 %cttz
31;
32  %cttz = call i16 @llvm.cttz.i16(i16 %a)
33  ret i16 %cttz
34}
35
36define i8 @test_cttz_i8(i8 %a) {
37;
38; CHECK-LABEL: 'test_cttz_i8'
39; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %cttz = call i8 @llvm.cttz.i8(i8 %a, i1 false)
40; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i8 %cttz
41;
42  %cttz = call i8 @llvm.cttz.i8(i8 %a)
43  ret i8 %cttz
44}
45
46declare i64 @llvm.cttz.i64(i64)
47declare i32 @llvm.cttz.i32(i32)
48declare i16 @llvm.cttz.i16(i16)
49declare i8 @llvm.cttz.i8(i8)
50
51; Verify the cost of vector cttz instructions.
52
53define <2 x i64> @test_cttz_v2i64(<2 x i64> %a) {
54;
55; CHECK-LABEL: 'test_cttz_v2i64'
56; CHECK-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %cttz = call <2 x i64> @llvm.cttz.v2i64(<2 x i64> %a, i1 true)
57; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i64> %cttz
58;
59  %cttz = call <2 x i64> @llvm.cttz.v2i64(<2 x i64> %a, i1 true)
60  ret <2 x i64> %cttz
61}
62
63define <2 x i32> @test_cttz_v2i32(<2 x i32> %a) {
64;
65; CHECK-LABEL: 'test_cttz_v2i32'
66; CHECK-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %cttz = call <2 x i32> @llvm.cttz.v2i32(<2 x i32> %a, i1 true)
67; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i32> %cttz
68;
69  %cttz = call <2 x i32> @llvm.cttz.v2i32(<2 x i32> %a, i1 true)
70  ret <2 x i32> %cttz
71}
72
73define <4 x i32> @test_cttz_v4i32(<4 x i32> %a) {
74;
75; CHECK-LABEL: 'test_cttz_v4i32'
76; CHECK-NEXT:  Cost Model: Found an estimated cost of 22 for instruction: %cttz = call <4 x i32> @llvm.cttz.v4i32(<4 x i32> %a, i1 true)
77; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i32> %cttz
78;
79  %cttz = call <4 x i32> @llvm.cttz.v4i32(<4 x i32> %a, i1 true)
80  ret <4 x i32> %cttz
81}
82
83define <2 x i16> @test_cttz_v2i16(<2 x i16> %a) {
84;
85; CHECK-LABEL: 'test_cttz_v2i16'
86; CHECK-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %cttz = call <2 x i16> @llvm.cttz.v2i16(<2 x i16> %a, i1 true)
87; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i16> %cttz
88;
89  %cttz = call <2 x i16> @llvm.cttz.v2i16(<2 x i16> %a, i1 true)
90  ret <2 x i16> %cttz
91}
92
93define <4 x i16> @test_cttz_v4i16(<4 x i16> %a) {
94;
95; CHECK-LABEL: 'test_cttz_v4i16'
96; CHECK-NEXT:  Cost Model: Found an estimated cost of 22 for instruction: %cttz = call <4 x i16> @llvm.cttz.v4i16(<4 x i16> %a, i1 true)
97; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i16> %cttz
98;
99  %cttz = call <4 x i16> @llvm.cttz.v4i16(<4 x i16> %a, i1 true)
100  ret <4 x i16> %cttz
101}
102
103define <8 x i16> @test_cttz_v8i16(<8 x i16> %a) {
104;
105; CHECK-LABEL: 'test_cttz_v8i16'
106; CHECK-NEXT:  Cost Model: Found an estimated cost of 50 for instruction: %cttz = call <8 x i16> @llvm.cttz.v8i16(<8 x i16> %a, i1 true)
107; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i16> %cttz
108;
109  %cttz = call <8 x i16> @llvm.cttz.v8i16(<8 x i16> %a, i1 true)
110  ret <8 x i16> %cttz
111}
112
113define <2 x i8> @test_cttz_v2i8(<2 x i8> %a) {
114;
115; CHECK-LABEL: 'test_cttz_v2i8'
116; CHECK-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %cttz = call <2 x i8> @llvm.cttz.v2i8(<2 x i8> %a, i1 true)
117; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i8> %cttz
118;
119  %cttz = call <2 x i8> @llvm.cttz.v2i8(<2 x i8> %a, i1 true)
120  ret <2 x i8> %cttz
121}
122
123define <4 x i8> @test_cttz_v4i8(<4 x i8> %a) {
124;
125; CHECK-LABEL: 'test_cttz_v4i8'
126; CHECK-NEXT:  Cost Model: Found an estimated cost of 22 for instruction: %cttz = call <4 x i8> @llvm.cttz.v4i8(<4 x i8> %a, i1 true)
127; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i8> %cttz
128;
129  %cttz = call <4 x i8> @llvm.cttz.v4i8(<4 x i8> %a, i1 true)
130  ret <4 x i8> %cttz
131}
132
133define <8 x i8> @test_cttz_v8i8(<8 x i8> %a) {
134;
135; CHECK-LABEL: 'test_cttz_v8i8'
136; CHECK-NEXT:  Cost Model: Found an estimated cost of 50 for instruction: %cttz = call <8 x i8> @llvm.cttz.v8i8(<8 x i8> %a, i1 true)
137; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i8> %cttz
138;
139  %cttz = call <8 x i8> @llvm.cttz.v8i8(<8 x i8> %a, i1 true)
140  ret <8 x i8> %cttz
141}
142
143define <16 x i8> @test_cttz_v16i8(<16 x i8> %a) {
144;
145; CHECK-LABEL: 'test_cttz_v16i8'
146; CHECK-NEXT:  Cost Model: Found an estimated cost of 106 for instruction: %cttz = call <16 x i8> @llvm.cttz.v16i8(<16 x i8> %a, i1 true)
147; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i8> %cttz
148;
149  %cttz = call <16 x i8> @llvm.cttz.v16i8(<16 x i8> %a, i1 true)
150  ret <16 x i8> %cttz
151}
152
153define <4 x i64> @test_cttz_v4i64(<4 x i64> %a) {
154;
155; CHECK-LABEL: 'test_cttz_v4i64'
156; CHECK-NEXT:  Cost Model: Found an estimated cost of 16 for instruction: %cttz = call <4 x i64> @llvm.cttz.v4i64(<4 x i64> %a, i1 true)
157; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i64> %cttz
158;
159  %cttz = call <4 x i64> @llvm.cttz.v4i64(<4 x i64> %a, i1 true)
160  ret <4 x i64> %cttz
161}
162
163define <8 x i32> @test_cttz_v8i32(<8 x i32> %a) {
164;
165; CHECK-LABEL: 'test_cttz_v8i32'
166; CHECK-NEXT:  Cost Model: Found an estimated cost of 44 for instruction: %cttz = call <8 x i32> @llvm.cttz.v8i32(<8 x i32> %a, i1 true)
167; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %cttz
168;
169  %cttz = call <8 x i32> @llvm.cttz.v8i32(<8 x i32> %a, i1 true)
170  ret <8 x i32> %cttz
171}
172
173define <16 x i16> @test_cttz_v16i16(<16 x i16> %a) {
174;
175; CHECK-LABEL: 'test_cttz_v16i16'
176; CHECK-NEXT:  Cost Model: Found an estimated cost of 100 for instruction: %cttz = call <16 x i16> @llvm.cttz.v16i16(<16 x i16> %a, i1 true)
177; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i16> %cttz
178;
179  %cttz = call <16 x i16> @llvm.cttz.v16i16(<16 x i16> %a, i1 true)
180  ret <16 x i16> %cttz
181}
182
183define <32 x i8> @test_cttz_v32i8(<32 x i8> %a) {
184;
185; CHECK-LABEL: 'test_cttz_v32i8'
186; CHECK-NEXT:  Cost Model: Found an estimated cost of 212 for instruction: %cttz = call <32 x i8> @llvm.cttz.v32i8(<32 x i8> %a, i1 true)
187; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <32 x i8> %cttz
188;
189  %cttz = call <32 x i8> @llvm.cttz.v32i8(<32 x i8> %a, i1 true)
190  ret <32 x i8> %cttz
191}
192
193declare <2 x i64> @llvm.cttz.v2i64(<2 x i64>, i1)
194declare <2 x i32> @llvm.cttz.v2i32(<2 x i32>, i1)
195declare <4 x i32> @llvm.cttz.v4i32(<4 x i32>, i1)
196declare <2 x i16> @llvm.cttz.v2i16(<2 x i16>, i1)
197declare <4 x i16> @llvm.cttz.v4i16(<4 x i16>, i1)
198declare <8 x i16> @llvm.cttz.v8i16(<8 x i16>, i1)
199declare <2 x i8> @llvm.cttz.v2i8(<2 x i8>, i1)
200declare <4 x i8> @llvm.cttz.v4i8(<4 x i8>, i1)
201declare <8 x i8> @llvm.cttz.v8i8(<8 x i8>, i1)
202declare <16 x i8> @llvm.cttz.v16i8(<16 x i8>, i1)
203
204declare <4 x i64> @llvm.cttz.v4i64(<4 x i64>, i1)
205declare <8 x i32> @llvm.cttz.v8i32(<8 x i32>, i1)
206declare <16 x i16> @llvm.cttz.v16i16(<16 x i16>, i1)
207declare <32 x i8> @llvm.cttz.v32i8(<32 x i8>, i1)
208