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