xref: /llvm-project/llvm/test/Analysis/CostModel/AArch64/ctpop.ll (revision faca9fdc4f79c24a51c585827de4c2d836c788fe)
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 ctpop instructions.
5
6target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
7
8define i64 @test_ctpop_i64(i64 %a) {
9; CHECK-LABEL: 'test_ctpop_i64'
10; CHECK-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %ctpop = call i64 @llvm.ctpop.i64(i64 %a)
11; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i64 %ctpop
12;
13  %ctpop = call i64 @llvm.ctpop.i64(i64 %a)
14  ret i64 %ctpop
15}
16
17define i32 @test_ctpop_i32(i32 %a) {
18; CHECK-LABEL: 'test_ctpop_i32'
19; CHECK-NEXT:  Cost Model: Found an estimated cost of 5 for instruction: %ctpop = call i32 @llvm.ctpop.i32(i32 %a)
20; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i32 %ctpop
21;
22  %ctpop = call i32 @llvm.ctpop.i32(i32 %a)
23  ret i32 %ctpop
24}
25
26define i16 @test_ctpop_i16(i16 %a) {
27; CHECK-LABEL: 'test_ctpop_i16'
28; CHECK-NEXT:  Cost Model: Found an estimated cost of 5 for instruction: %ctpop = call i16 @llvm.ctpop.i16(i16 %a)
29; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i16 %ctpop
30;
31  %ctpop = call i16 @llvm.ctpop.i16(i16 %a)
32  ret i16 %ctpop
33}
34
35define i8 @test_ctpop_i8(i8 %a) {
36; CHECK-LABEL: 'test_ctpop_i8'
37; CHECK-NEXT:  Cost Model: Found an estimated cost of 5 for instruction: %ctpop = call i8 @llvm.ctpop.i8(i8 %a)
38; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i8 %ctpop
39;
40  %ctpop = call i8 @llvm.ctpop.i8(i8 %a)
41  ret i8 %ctpop
42}
43
44declare i64 @llvm.ctpop.i64(i64)
45declare i32 @llvm.ctpop.i32(i32)
46declare i16 @llvm.ctpop.i16(i16)
47declare i8 @llvm.ctpop.i8(i8)
48
49; Verify the cost of vector ctpop instructions.
50
51define <2 x i64> @test_ctpop_v2i64(<2 x i64> %a) {
52; CHECK-LABEL: 'test_ctpop_v2i64'
53; CHECK-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %ctpop = call <2 x i64> @llvm.ctpop.v2i64(<2 x i64> %a)
54; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i64> %ctpop
55;
56  %ctpop = call <2 x i64> @llvm.ctpop.v2i64(<2 x i64> %a)
57  ret <2 x i64> %ctpop
58}
59
60define <2 x i32> @test_ctpop_v2i32(<2 x i32> %a) {
61; CHECK-LABEL: 'test_ctpop_v2i32'
62; CHECK-NEXT:  Cost Model: Found an estimated cost of 3 for instruction: %ctpop = call <2 x i32> @llvm.ctpop.v2i32(<2 x i32> %a)
63; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i32> %ctpop
64;
65  %ctpop = call <2 x i32> @llvm.ctpop.v2i32(<2 x i32> %a)
66  ret <2 x i32> %ctpop
67}
68
69define <4 x i32> @test_ctpop_v4i32(<4 x i32> %a) {
70; CHECK-LABEL: 'test_ctpop_v4i32'
71; CHECK-NEXT:  Cost Model: Found an estimated cost of 3 for instruction: %ctpop = call <4 x i32> @llvm.ctpop.v4i32(<4 x i32> %a)
72; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i32> %ctpop
73;
74  %ctpop = call <4 x i32> @llvm.ctpop.v4i32(<4 x i32> %a)
75  ret <4 x i32> %ctpop
76}
77
78define <2 x i16> @test_ctpop_v2i16(<2 x i16> %a) {
79; CHECK-LABEL: 'test_ctpop_v2i16'
80; CHECK-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %ctpop = call <2 x i16> @llvm.ctpop.v2i16(<2 x i16> %a)
81; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i16> %ctpop
82;
83  %ctpop = call <2 x i16> @llvm.ctpop.v2i16(<2 x i16> %a)
84  ret <2 x i16> %ctpop
85}
86
87define <4 x i16> @test_ctpop_v4i16(<4 x i16> %a) {
88; CHECK-LABEL: 'test_ctpop_v4i16'
89; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %ctpop = call <4 x i16> @llvm.ctpop.v4i16(<4 x i16> %a)
90; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i16> %ctpop
91;
92  %ctpop = call <4 x i16> @llvm.ctpop.v4i16(<4 x i16> %a)
93  ret <4 x i16> %ctpop
94}
95
96define <8 x i16> @test_ctpop_v8i16(<8 x i16> %a) {
97; CHECK-LABEL: 'test_ctpop_v8i16'
98; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %ctpop = call <8 x i16> @llvm.ctpop.v8i16(<8 x i16> %a)
99; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i16> %ctpop
100;
101  %ctpop = call <8 x i16> @llvm.ctpop.v8i16(<8 x i16> %a)
102  ret <8 x i16> %ctpop
103}
104
105define <2 x i8> @test_ctpop_v2i8(<2 x i8> %a) {
106; CHECK-LABEL: 'test_ctpop_v2i8'
107; CHECK-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %ctpop = call <2 x i8> @llvm.ctpop.v2i8(<2 x i8> %a)
108; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i8> %ctpop
109;
110  %ctpop = call <2 x i8> @llvm.ctpop.v2i8(<2 x i8> %a)
111  ret <2 x i8> %ctpop
112}
113
114define <4 x i8> @test_ctpop_v4i8(<4 x i8> %a) {
115; CHECK-LABEL: 'test_ctpop_v4i8'
116; CHECK-NEXT:  Cost Model: Found an estimated cost of 3 for instruction: %ctpop = call <4 x i8> @llvm.ctpop.v4i8(<4 x i8> %a)
117; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i8> %ctpop
118;
119  %ctpop = call <4 x i8> @llvm.ctpop.v4i8(<4 x i8> %a)
120  ret <4 x i8> %ctpop
121}
122
123define <8 x i8> @test_ctpop_v8i8(<8 x i8> %a) {
124; CHECK-LABEL: 'test_ctpop_v8i8'
125; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %ctpop = call <8 x i8> @llvm.ctpop.v8i8(<8 x i8> %a)
126; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i8> %ctpop
127;
128  %ctpop = call <8 x i8> @llvm.ctpop.v8i8(<8 x i8> %a)
129  ret <8 x i8> %ctpop
130}
131
132define <16 x i8> @test_ctpop_v16i8(<16 x i8> %a) {
133; CHECK-LABEL: 'test_ctpop_v16i8'
134; CHECK-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %ctpop = call <16 x i8> @llvm.ctpop.v16i8(<16 x i8> %a)
135; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i8> %ctpop
136;
137  %ctpop = call <16 x i8> @llvm.ctpop.v16i8(<16 x i8> %a)
138  ret <16 x i8> %ctpop
139}
140
141define <4 x i64> @test_ctpop_v4i64(<4 x i64> %a) {
142; CHECK-LABEL: 'test_ctpop_v4i64'
143; CHECK-NEXT:  Cost Model: Found an estimated cost of 8 for instruction: %ctpop = call <4 x i64> @llvm.ctpop.v4i64(<4 x i64> %a)
144; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <4 x i64> %ctpop
145;
146  %ctpop = call <4 x i64> @llvm.ctpop.v4i64(<4 x i64> %a)
147  ret <4 x i64> %ctpop
148}
149
150define <8 x i32> @test_ctpop_v8i32(<8 x i32> %a) {
151; CHECK-LABEL: 'test_ctpop_v8i32'
152; CHECK-NEXT:  Cost Model: Found an estimated cost of 6 for instruction: %ctpop = call <8 x i32> @llvm.ctpop.v8i32(<8 x i32> %a)
153; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <8 x i32> %ctpop
154;
155  %ctpop = call <8 x i32> @llvm.ctpop.v8i32(<8 x i32> %a)
156  ret <8 x i32> %ctpop
157}
158
159define <16 x i16> @test_ctpop_v16i16(<16 x i16> %a) {
160; CHECK-LABEL: 'test_ctpop_v16i16'
161; CHECK-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: %ctpop = call <16 x i16> @llvm.ctpop.v16i16(<16 x i16> %a)
162; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <16 x i16> %ctpop
163;
164  %ctpop = call <16 x i16> @llvm.ctpop.v16i16(<16 x i16> %a)
165  ret <16 x i16> %ctpop
166}
167
168define <32 x i8> @test_ctpop_v32i8(<32 x i8> %a) {
169; CHECK-LABEL: 'test_ctpop_v32i8'
170; CHECK-NEXT:  Cost Model: Found an estimated cost of 2 for instruction: %ctpop = call <32 x i8> @llvm.ctpop.v32i8(<32 x i8> %a)
171; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <32 x i8> %ctpop
172;
173  %ctpop = call <32 x i8> @llvm.ctpop.v32i8(<32 x i8> %a)
174  ret <32 x i8> %ctpop
175}
176
177define i64 @test_ctpop_noneon_i64(i64 %a) "target-features"="-fp-armv8,-neon" {
178; CHECK-LABEL: 'test_ctpop_noneon_i64'
179; CHECK-NEXT:  Cost Model: Found an estimated cost of 12 for instruction: %ctpop = call i64 @llvm.ctpop.i64(i64 %a)
180; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret i64 %ctpop
181;
182  %ctpop = call i64 @llvm.ctpop.i64(i64 %a)
183  ret i64 %ctpop
184}
185
186define <2 x i64> @test_ctpop_noneon_v2i64(<2 x i64> %a) "target-features"="-fp-armv8,-neon" {
187; CHECK-LABEL: 'test_ctpop_noneon_v2i64'
188; CHECK-NEXT:  Cost Model: Found an estimated cost of 24 for instruction: %ctpop = call <2 x i64> @llvm.ctpop.v2i64(<2 x i64> %a)
189; CHECK-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: ret <2 x i64> %ctpop
190;
191  %ctpop = call <2 x i64> @llvm.ctpop.v2i64(<2 x i64> %a)
192  ret <2 x i64> %ctpop
193}
194
195declare <2 x i64> @llvm.ctpop.v2i64(<2 x i64>)
196declare <2 x i32> @llvm.ctpop.v2i32(<2 x i32>)
197declare <4 x i32> @llvm.ctpop.v4i32(<4 x i32>)
198declare <2 x i16> @llvm.ctpop.v2i16(<2 x i16>)
199declare <4 x i16> @llvm.ctpop.v4i16(<4 x i16>)
200declare <8 x i16> @llvm.ctpop.v8i16(<8 x i16>)
201declare <2 x i8> @llvm.ctpop.v2i8(<2 x i8>)
202declare <4 x i8> @llvm.ctpop.v4i8(<4 x i8>)
203declare <8 x i8> @llvm.ctpop.v8i8(<8 x i8>)
204declare <16 x i8> @llvm.ctpop.v16i8(<16 x i8>)
205
206declare <4 x i64> @llvm.ctpop.v4i64(<4 x i64>)
207declare <8 x i32> @llvm.ctpop.v8i32(<8 x i32>)
208declare <16 x i16> @llvm.ctpop.v16i16(<16 x i16>)
209declare <32 x i8> @llvm.ctpop.v32i8(<32 x i8>)
210