• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -cost-model -analyze -mtriple=systemz-unknown -mcpu=z13 | FileCheck %s
2
3; Check costs of divisions by register
4;
5; Note: Vectorization of division/remainder is temporarily disabled for high
6; vectorization factors by returning 1000.
7
8; Scalar sdiv
9
10define i64 @fun0(i64 %a, i64 %b) {
11  %r = sdiv i64 %a, %b
12  ret i64 %r
13; CHECK: Cost Model: Found an estimated cost of 20 for instruction:   %r = sdiv i64
14}
15
16define i32 @fun1(i32 %a, i32 %b) {
17  %r = sdiv i32 %a, %b
18  ret i32 %r
19; CHECK: Cost Model: Found an estimated cost of 20 for instruction:   %r = sdiv i32 %a, %b
20}
21
22define i16 @fun2(i16 %a, i16 %b) {
23  %r = sdiv i16 %a, %b
24  ret i16 %r
25; CHECK: Cost Model: Found an estimated cost of 20 for instruction:   %r = sdiv i16 %a, %b
26}
27
28define i8 @fun3(i8 %a, i8 %b) {
29  %r = sdiv i8 %a, %b
30  ret i8 %r
31; CHECK: Cost Model: Found an estimated cost of 20 for instruction:   %r = sdiv i8 %a, %b
32}
33
34; Vector sdiv
35
36define <2 x i64> @fun4(<2 x i64> %a, <2 x i64> %b) {
37  %r = sdiv <2 x i64> %a, %b
38  ret <2 x i64> %r
39; CHECK: Cost Model: Found an estimated cost of 47 for instruction:   %r = sdiv <2 x i64>
40}
41
42define <4 x i32> @fun5(<4 x i32> %a, <4 x i32> %b) {
43  %r = sdiv <4 x i32> %a, %b
44  ret <4 x i32> %r
45; CHECK: Cost Model: Found an estimated cost of 94 for instruction:   %r = sdiv <4 x i32>
46}
47
48define <2 x i32> @fun6(<2 x i32> %a, <2 x i32> %b) {
49  %r = sdiv <2 x i32> %a, %b
50  ret <2 x i32> %r
51; CHECK: Cost Model: Found an estimated cost of 48 for instruction:   %r = sdiv <2 x i32>
52}
53
54define <8 x i16> @fun7(<8 x i16> %a, <8 x i16> %b) {
55  %r = sdiv <8 x i16> %a, %b
56  ret <8 x i16> %r
57; CHECK: Cost Model: Found an estimated cost of 1000 for instruction:   %r = sdiv <8 x i16>
58}
59
60define <4 x i16> @fun8(<4 x i16> %a, <4 x i16> %b) {
61  %r = sdiv <4 x i16> %a, %b
62  ret <4 x i16> %r
63; CHECK: Cost Model: Found an estimated cost of 94 for instruction:   %r = sdiv <4 x i16>
64}
65
66define <16 x i8> @fun9(<16 x i8> %a, <16 x i8> %b) {
67  %r = sdiv <16 x i8> %a, %b
68  ret <16 x i8> %r
69; CHECK: Cost Model: Found an estimated cost of 1000 for instruction:   %r = sdiv <16 x i8>
70}
71
72define <8 x i8> @fun10(<8 x i8> %a, <8 x i8> %b) {
73  %r = sdiv <8 x i8> %a, %b
74  ret <8 x i8> %r
75; CHECK: Cost Model: Found an estimated cost of 1000 for instruction:   %r = sdiv <8 x i8>
76}
77
78; Scalar udiv
79
80define i64 @fun11(i64 %a, i64 %b) {
81  %r = udiv i64 %a, %b
82  ret i64 %r
83; CHECK: Cost Model: Found an estimated cost of 20 for instruction:   %r = udiv i64 %a, %b
84}
85
86define i32 @fun12(i32 %a, i32 %b) {
87  %r = udiv i32 %a, %b
88  ret i32 %r
89; CHECK: Cost Model: Found an estimated cost of 20 for instruction:   %r = udiv i32
90}
91
92define i16 @fun13(i16 %a, i16 %b) {
93  %r = udiv i16 %a, %b
94  ret i16 %r
95; CHECK: Cost Model: Found an estimated cost of 20 for instruction:   %r = udiv i16
96}
97
98define i8 @fun14(i8 %a, i8 %b) {
99  %r = udiv i8 %a, %b
100  ret i8 %r
101; CHECK: Cost Model: Found an estimated cost of 20 for instruction:   %r = udiv i8
102}
103
104; Vector udiv
105
106define <2 x i64> @fun15(<2 x i64> %a, <2 x i64> %b) {
107  %r = udiv <2 x i64> %a, %b
108  ret <2 x i64> %r
109; CHECK: Cost Model: Found an estimated cost of 47 for instruction:   %r = udiv <2 x i64>
110}
111
112define <4 x i32> @fun16(<4 x i32> %a, <4 x i32> %b) {
113  %r = udiv <4 x i32> %a, %b
114  ret <4 x i32> %r
115; CHECK: Cost Model: Found an estimated cost of 94 for instruction:   %r = udiv <4 x i32>
116}
117
118define <2 x i32> @fun17(<2 x i32> %a, <2 x i32> %b) {
119  %r = udiv <2 x i32> %a, %b
120  ret <2 x i32> %r
121; CHECK: Cost Model: Found an estimated cost of 48 for instruction:   %r = udiv <2 x i32>
122}
123
124define <8 x i16> @fun18(<8 x i16> %a, <8 x i16> %b) {
125  %r = udiv <8 x i16> %a, %b
126  ret <8 x i16> %r
127; CHECK: Cost Model: Found an estimated cost of 1000 for instruction:   %r = udiv <8 x i16>
128}
129
130define <4 x i16> @fun19(<4 x i16> %a, <4 x i16> %b) {
131  %r = udiv <4 x i16> %a, %b
132  ret <4 x i16> %r
133; CHECK: Cost Model: Found an estimated cost of 94 for instruction:   %r = udiv <4 x i16>
134}
135
136define <16 x i8> @fun20(<16 x i8> %a, <16 x i8> %b) {
137  %r = udiv <16 x i8> %a, %b
138  ret <16 x i8> %r
139; CHECK: Cost Model: Found an estimated cost of 1000 for instruction:   %r = udiv <16 x i8>
140}
141
142define <8 x i8> @fun21(<8 x i8> %a, <8 x i8> %b) {
143  %r = udiv <8 x i8> %a, %b
144  ret <8 x i8> %r
145; CHECK: Cost Model: Found an estimated cost of 1000 for instruction:   %r = udiv <8 x i8>
146}
147
148; Scalar srem
149
150define i64 @fun22(i64 %a, i64 %b) {
151  %r = srem i64 %a, %b
152  ret i64 %r
153; CHECK: Cost Model: Found an estimated cost of 20 for instruction:   %r = srem i64
154}
155
156define i32 @fun23(i32 %a, i32 %b) {
157  %r = srem i32 %a, %b
158  ret i32 %r
159; CHECK: Cost Model: Found an estimated cost of 20 for instruction:   %r = srem i32
160}
161
162define i16 @fun24(i16 %a, i16 %b) {
163  %r = srem i16 %a, %b
164  ret i16 %r
165; CHECK: Cost Model: Found an estimated cost of 20 for instruction:   %r = srem i16
166}
167
168define i8 @fun25(i8 %a, i8 %b) {
169  %r = srem i8 %a, %b
170  ret i8 %r
171; CHECK: Cost Model: Found an estimated cost of 20 for instruction:   %r = srem i8
172}
173
174; Vector srem
175
176define <2 x i64> @fun26(<2 x i64> %a, <2 x i64> %b) {
177  %r = srem <2 x i64> %a, %b
178  ret <2 x i64> %r
179; CHECK: Cost Model: Found an estimated cost of 47 for instruction:   %r = srem <2 x i64>
180}
181
182define <4 x i32> @fun27(<4 x i32> %a, <4 x i32> %b) {
183  %r = srem <4 x i32> %a, %b
184  ret <4 x i32> %r
185; CHECK: Cost Model: Found an estimated cost of 94 for instruction:   %r = srem <4 x i32>
186}
187
188define <2 x i32> @fun28(<2 x i32> %a, <2 x i32> %b) {
189  %r = srem <2 x i32> %a, %b
190  ret <2 x i32> %r
191; CHECK: Cost Model: Found an estimated cost of 48 for instruction:   %r = srem <2 x i32>
192}
193
194define <8 x i16> @fun29(<8 x i16> %a, <8 x i16> %b) {
195  %r = srem <8 x i16> %a, %b
196  ret <8 x i16> %r
197; CHECK: ost Model: Found an estimated cost of 1000 for instruction:   %r = srem <8 x i16>
198}
199
200define <4 x i16> @fun30(<4 x i16> %a, <4 x i16> %b) {
201  %r = srem <4 x i16> %a, %b
202  ret <4 x i16> %r
203; CHECK: Cost Model: Found an estimated cost of 94 for instruction:   %r = srem <4 x i16>
204}
205
206define <16 x i8> @fun31(<16 x i8> %a, <16 x i8> %b) {
207  %r = srem <16 x i8> %a, %b
208  ret <16 x i8> %r
209; CHECK: Cost Model: Found an estimated cost of 1000 for instruction:   %r = srem <16 x i8>
210}
211
212define <8 x i8> @fun32(<8 x i8> %a, <8 x i8> %b) {
213  %r = srem <8 x i8> %a, %b
214  ret <8 x i8> %r
215; CHECK: Cost Model: Found an estimated cost of 1000 for instruction:   %r = srem <8 x i8>
216}
217
218; Scalar urem
219
220define i64 @fun33(i64 %a, i64 %b) {
221  %r = urem i64 %a, %b
222  ret i64 %r
223; CHECK: Cost Model: Found an estimated cost of 20 for instruction:   %r = urem i64
224}
225
226define i32 @fun34(i32 %a, i32 %b) {
227  %r = urem i32 %a, %b
228  ret i32 %r
229; CHECK: Cost Model: Found an estimated cost of 20 for instruction:   %r = urem i32
230}
231
232define i16 @fun35(i16 %a, i16 %b) {
233  %r = urem i16 %a, %b
234  ret i16 %r
235; CHECK: Cost Model: Found an estimated cost of 20 for instruction:   %r = urem i16
236}
237
238define i8 @fun36(i8 %a, i8 %b) {
239  %r = urem i8 %a, %b
240  ret i8 %r
241; CHECK: Cost Model: Found an estimated cost of 20 for instruction:   %r = urem i8
242}
243
244; Vector urem
245
246define <2 x i64> @fun37(<2 x i64> %a, <2 x i64> %b) {
247  %r = urem <2 x i64> %a, %b
248  ret <2 x i64> %r
249; CHECK: Cost Model: Found an estimated cost of 47 for instruction:   %r = urem <2 x i64>
250}
251
252define <4 x i32> @fun38(<4 x i32> %a, <4 x i32> %b) {
253  %r = urem <4 x i32> %a, %b
254  ret <4 x i32> %r
255; CHECK: Cost Model: Found an estimated cost of 94 for instruction:   %r = urem <4 x i32>
256}
257
258define <2 x i32> @fun39(<2 x i32> %a, <2 x i32> %b) {
259  %r = urem <2 x i32> %a, %b
260  ret <2 x i32> %r
261; CHECK: Cost Model: Found an estimated cost of 48 for instruction:   %r = urem <2 x i32>
262}
263
264define <8 x i16> @fun40(<8 x i16> %a, <8 x i16> %b) {
265  %r = urem <8 x i16> %a, %b
266  ret <8 x i16> %r
267; CHECK: Cost Model: Found an estimated cost of 1000 for instruction:   %r = urem <8 x i16>
268}
269
270define <4 x i16> @fun41(<4 x i16> %a, <4 x i16> %b) {
271  %r = urem <4 x i16> %a, %b
272  ret <4 x i16> %r
273; CHECK: Cost Model: Found an estimated cost of 94 for instruction:   %r = urem <4 x i16>
274}
275
276define <16 x i8> @fun42(<16 x i8> %a, <16 x i8> %b) {
277  %r = urem <16 x i8> %a, %b
278  ret <16 x i8> %r
279; CHECK: Cost Model: Found an estimated cost of 1000 for instruction:   %r = urem <16 x i8>
280}
281
282define <8 x i8> @fun43(<8 x i8> %a, <8 x i8> %b) {
283  %r = urem <8 x i8> %a, %b
284  ret <8 x i8> %r
285; CHECK: Cost Model: Found an estimated cost of 1000 for instruction:   %r = urem <8 x i8>
286}
287