• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -cost-model -analyze -mtriple=systemz-unknown -mcpu=z13 \
2; RUN:  | FileCheck %s -check-prefix=COST
3
4; Check that all divide/remainder instructions are implemented by cheaper instructions.
5; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 -o - | FileCheck %s
6; CHECK-NOT: dsg
7; CHECK-NOT: dl
8
9; Scalar sdiv
10
11define i64 @fun0(i64 %a) {
12  %r = sdiv i64 %a, 2
13  ret i64 %r
14; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv i64 %a, 2
15}
16
17define i64 @fun1(i64 %a) {
18  %r = sdiv i64 %a, -4
19  ret i64 %r
20; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv i64 %a, -4
21}
22
23define i32 @fun2(i32 %a) {
24  %r = sdiv i32 %a, 8
25  ret i32 %r
26; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv i32 %a, 8
27}
28
29define i32 @fun3(i32 %a) {
30  %r = sdiv i32 %a, -16
31  ret i32 %r
32; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv i32 %a, -16
33}
34
35define i16 @fun4(i16 %a) {
36  %r = sdiv i16 %a, 32
37  ret i16 %r
38; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv i16 %a, 32
39}
40
41define i16 @fun5(i16 %a) {
42  %r = sdiv i16 %a, -64
43  ret i16 %r
44; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv i16 %a, -64
45}
46
47define i8 @fun6(i8 %a) {
48  %r = sdiv i8 %a, 64
49  ret i8 %r
50; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv i8 %a, 64
51}
52
53define i8 @fun7(i8 %a) {
54  %r = sdiv i8 %a, -128
55  ret i8 %r
56; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv i8 %a, -128
57}
58
59; Vector sdiv
60
61define <2 x i64> @fun8(<2 x i64> %a) {
62  %r = sdiv <2 x i64> %a, <i64 2, i64 2>
63  ret <2 x i64> %r
64; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <2 x i64> %a, <i64 2, i64 2>
65}
66
67define <2 x i64> @fun9(<2 x i64> %a) {
68  %r = sdiv <2 x i64> %a, <i64 -4, i64 -4>
69  ret <2 x i64> %r
70; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <2 x i64> %a, <i64 -4, i64 -4>
71}
72
73define <4 x i32> @fun10(<4 x i32> %a) {
74  %r = sdiv <4 x i32> %a, <i32 8, i32 8, i32 8, i32 8>
75  ret <4 x i32> %r
76; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <4 x i32> %a, <i32 8, i32 8, i32 8, i32 8>
77}
78
79define <4 x i32> @fun11(<4 x i32> %a) {
80  %r = sdiv <4 x i32> %a, <i32 -16, i32 -16, i32 -16, i32 -16>
81  ret <4 x i32> %r
82; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <4 x i32> %a, <i32 -16
83}
84
85define <2 x i32> @fun12(<2 x i32> %a) {
86  %r = sdiv <2 x i32> %a, <i32 -16, i32 -16>
87  ret <2 x i32> %r
88; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <2 x i32> %a, <i32 -16
89}
90
91define <8 x i16> @fun13(<8 x i16> %a) {
92  %r = sdiv <8 x i16> %a, <i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32>
93  ret <8 x i16> %r
94; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <8 x i16> %a, <i16 32
95}
96
97define <8 x i16> @fun14(<8 x i16> %a) {
98  %r = sdiv <8 x i16> %a, <i16 -64, i16 -64, i16 -64, i16 -64, i16 -64, i16 -64, i16 -64, i16 -64>
99  ret <8 x i16> %r
100; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <8 x i16> %a, <i16 -64
101}
102
103define <4 x i16> @fun15(<4 x i16> %a) {
104  %r = sdiv <4 x i16> %a, <i16 32, i16 32, i16 32, i16 32>
105  ret <4 x i16> %r
106; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <4 x i16> %a, <i16 32
107}
108
109define <16 x i8> @fun16(<16 x i8> %a) {
110  %r = sdiv <16 x i8> %a, <i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64>
111  ret <16 x i8> %r
112; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <16 x i8> %a, <i8 64
113}
114
115define <16 x i8> @fun17(<16 x i8> %a) {
116  %r = sdiv <16 x i8> %a, <i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128>
117  ret <16 x i8> %r
118; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <16 x i8> %a, <i8 -128
119}
120
121define <8 x i8> @fun18(<8 x i8> %a) {
122  %r = sdiv <8 x i8> %a, <i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128>
123  ret <8 x i8> %r
124; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = sdiv <8 x i8> %a, <i8 -128
125}
126
127; Scalar udiv
128
129define i64 @fun19(i64 %a) {
130  %r = udiv i64 %a, 2
131  ret i64 %r
132; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv i64 %a, 2
133}
134
135define i32 @fun20(i32 %a) {
136  %r = udiv i32 %a, 8
137  ret i32 %r
138; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv i32 %a, 8
139}
140
141define i16 @fun21(i16 %a) {
142  %r = udiv i16 %a, 32
143  ret i16 %r
144; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv i16 %a, 32
145}
146
147define i8 @fun22(i8 %a) {
148  %r = udiv i8 %a, 128
149  ret i8 %r
150; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv i8 %a, -128
151}
152
153; Vector udiv
154
155define <2 x i64> @fun23(<2 x i64> %a) {
156  %r = udiv <2 x i64> %a, <i64 2, i64 2>
157  ret <2 x i64> %r
158; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv <2 x i64> %a, <i64 2
159}
160
161define <4 x i32> @fun24(<4 x i32> %a) {
162  %r = udiv <4 x i32> %a, <i32 8, i32 8, i32 8, i32 8>
163  ret <4 x i32> %r
164; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv <4 x i32> %a, <i32 8
165}
166
167define <2 x i32> @fun25(<2 x i32> %a) {
168  %r = udiv <2 x i32> %a, <i32 8, i32 8>
169  ret <2 x i32> %r
170; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv <2 x i32> %a, <i32 8
171}
172
173define <8 x i16> @fun26(<8 x i16> %a) {
174  %r = udiv <8 x i16> %a, <i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32>
175  ret <8 x i16> %r
176; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv <8 x i16> %a, <i16 32
177}
178
179define <4 x i16> @fun27(<4 x i16> %a) {
180  %r = udiv <4 x i16> %a, <i16 32, i16 32, i16 32, i16 32>
181  ret <4 x i16> %r
182; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv <4 x i16> %a, <i16 32
183}
184
185define <16 x i8> @fun28(<16 x i8> %a) {
186  %r = udiv <16 x i8> %a, <i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128>
187  ret <16 x i8> %r
188; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv <16 x i8> %a, <i8 -128
189}
190
191define <8 x i8> @fun29(<8 x i8> %a) {
192  %r = udiv <8 x i8> %a, <i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128>
193  ret <8 x i8> %r
194; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = udiv <8 x i8> %a, <i8 -128
195}
196
197; Scalar srem
198
199define i64 @fun30(i64 %a) {
200  %r = srem i64 %a, 2
201  ret i64 %r
202; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem i64 %a, 2
203}
204
205define i64 @fun31(i64 %a) {
206  %r = srem i64 %a, -4
207  ret i64 %r
208; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem i64 %a, -4
209}
210
211define i32 @fun32(i32 %a) {
212  %r = srem i32 %a, 8
213  ret i32 %r
214; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem i32 %a, 8
215}
216
217define i32 @fun33(i32 %a) {
218  %r = srem i32 %a, -16
219  ret i32 %r
220; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem i32 %a, -16
221}
222
223define i16 @fun34(i16 %a) {
224  %r = srem i16 %a, 32
225  ret i16 %r
226; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem i16 %a, 32
227}
228
229define i16 @fun35(i16 %a) {
230  %r = srem i16 %a, -64
231  ret i16 %r
232; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem i16 %a, -64
233}
234
235define i8 @fun36(i8 %a) {
236  %r = srem i8 %a, 64
237  ret i8 %r
238; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem i8 %a, 64
239}
240
241define i8 @fun37(i8 %a) {
242  %r = srem i8 %a, -128
243  ret i8 %r
244; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem i8 %a, -128
245}
246
247; Vector srem
248
249define <2 x i64> @fun38(<2 x i64> %a) {
250  %r = srem <2 x i64> %a, <i64 2, i64 2>
251  ret <2 x i64> %r
252; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem <2 x i64> %a, <i64 2, i64 2>
253}
254
255define <2 x i64> @fun39(<2 x i64> %a) {
256  %r = srem <2 x i64> %a, <i64 -4, i64 -4>
257  ret <2 x i64> %r
258; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem <2 x i64> %a, <i64 -4, i64 -4>
259}
260
261define <4 x i32> @fun40(<4 x i32> %a) {
262  %r = srem <4 x i32> %a, <i32 8, i32 8, i32 8, i32 8>
263  ret <4 x i32> %r
264; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem <4 x i32> %a, <i32 8, i32 8, i32 8, i32 8>
265}
266
267define <4 x i32> @fun41(<4 x i32> %a) {
268  %r = srem <4 x i32> %a, <i32 -16, i32 -16, i32 -16, i32 -16>
269  ret <4 x i32> %r
270; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem <4 x i32> %a, <i32 -16
271}
272
273define <2 x i32> @fun42(<2 x i32> %a) {
274  %r = srem <2 x i32> %a, <i32 -16, i32 -16>
275  ret <2 x i32> %r
276; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem <2 x i32> %a, <i32 -16
277}
278
279define <8 x i16> @fun43(<8 x i16> %a) {
280  %r = srem <8 x i16> %a, <i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32>
281  ret <8 x i16> %r
282; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem <8 x i16> %a, <i16 32
283}
284
285define <8 x i16> @fun44(<8 x i16> %a) {
286  %r = srem <8 x i16> %a, <i16 -64, i16 -64, i16 -64, i16 -64, i16 -64, i16 -64, i16 -64, i16 -64>
287  ret <8 x i16> %r
288; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem <8 x i16> %a, <i16 -64
289}
290
291define <4 x i16> @fun45(<4 x i16> %a) {
292  %r = srem <4 x i16> %a, <i16 32, i16 32, i16 32, i16 32>
293  ret <4 x i16> %r
294; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem <4 x i16> %a, <i16 32
295}
296
297define <16 x i8> @fun46(<16 x i8> %a) {
298  %r = srem <16 x i8> %a, <i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64>
299  ret <16 x i8> %r
300; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem <16 x i8> %a, <i8 64
301}
302
303define <16 x i8> @fun47(<16 x i8> %a) {
304  %r = srem <16 x i8> %a, <i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128>
305  ret <16 x i8> %r
306; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem <16 x i8> %a, <i8 -128
307}
308
309define <8 x i8> @fun48(<8 x i8> %a) {
310  %r = srem <8 x i8> %a, <i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128>
311  ret <8 x i8> %r
312; COST: Cost Model: Found an estimated cost of 4 for instruction:   %r = srem <8 x i8> %a, <i8 -128
313}
314
315; Scalar urem
316
317define i64 @fun49(i64 %a) {
318  %r = urem i64 %a, 2
319  ret i64 %r
320; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = urem i64 %a, 2
321}
322
323define i32 @fun50(i32 %a) {
324  %r = urem i32 %a, 8
325  ret i32 %r
326; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = urem i32 %a, 8
327}
328
329define i16 @fun51(i16 %a) {
330  %r = urem i16 %a, 32
331  ret i16 %r
332; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = urem i16 %a, 32
333}
334
335define i8 @fun52(i8 %a) {
336  %r = urem i8 %a, 128
337  ret i8 %r
338; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = urem i8 %a, -128
339}
340
341; Vector urem
342
343define <2 x i64> @fun53(<2 x i64> %a) {
344  %r = urem <2 x i64> %a, <i64 2, i64 2>
345  ret <2 x i64> %r
346; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = urem <2 x i64> %a, <i64 2
347}
348
349define <4 x i32> @fun54(<4 x i32> %a) {
350  %r = urem <4 x i32> %a, <i32 8, i32 8, i32 8, i32 8>
351  ret <4 x i32> %r
352; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = urem <4 x i32> %a, <i32 8
353}
354
355define <2 x i32> @fun55(<2 x i32> %a) {
356  %r = urem <2 x i32> %a, <i32 8, i32 8>
357  ret <2 x i32> %r
358; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = urem <2 x i32> %a, <i32 8
359}
360
361define <8 x i16> @fun56(<8 x i16> %a) {
362  %r = urem <8 x i16> %a, <i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32, i16 32>
363  ret <8 x i16> %r
364; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = urem <8 x i16> %a, <i16 32
365}
366
367define <4 x i16> @fun57(<4 x i16> %a) {
368  %r = urem <4 x i16> %a, <i16 32, i16 32, i16 32, i16 32>
369  ret <4 x i16> %r
370; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = urem <4 x i16> %a, <i16 32
371}
372
373define <16 x i8> @fun58(<16 x i8> %a) {
374  %r = urem <16 x i8> %a, <i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128>
375  ret <16 x i8> %r
376; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = urem <16 x i8> %a, <i8 -128
377}
378
379define <8 x i8> @fun59(<8 x i8> %a) {
380  %r = urem <8 x i8> %a, <i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128, i8 128>
381  ret <8 x i8> %r
382; COST: Cost Model: Found an estimated cost of 1 for instruction:   %r = urem <8 x i8> %a, <i8 -128
383}
384