1 ; RUN: opt < %s -cost-model -analyze -mtriple=systemz-unknown -mcpu=z13 \
2 ; RUN: | FileCheck %s -check-prefix=COST
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
11 define i64 @fun0(i64 %a) {
14 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i64 %a, 2
17 define i64 @fun1(i64 %a) {
20 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i64 %a, -4
23 define i32 @fun2(i32 %a) {
26 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i32 %a, 8
29 define i32 @fun3(i32 %a) {
32 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i32 %a, -16
35 define i16 @fun4(i16 %a) {
38 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i16 %a, 32
41 define i16 @fun5(i16 %a) {
44 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i16 %a, -64
47 define i8 @fun6(i8 %a) {
50 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i8 %a, 64
53 define i8 @fun7(i8 %a) {
56 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv i8 %a, -128
61 define <2 x i64> @fun8(<2 x i64> %a) {
62 %r = sdiv <2 x i64> %a, <i64 2, i64 2>
64 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <2 x i64> %a, <i64 2, i64 2>
67 define <2 x i64> @fun9(<2 x i64> %a) {
68 %r = sdiv <2 x i64> %a, <i64 -4, i64 -4>
70 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <2 x i64> %a, <i64 -4, i64 -4>
73 define <4 x i32> @fun10(<4 x i32> %a) {
74 %r = sdiv <4 x i32> %a, <i32 8, i32 8, i32 8, i32 8>
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>
79 define <4 x i32> @fun11(<4 x i32> %a) {
80 %r = sdiv <4 x i32> %a, <i32 -16, i32 -16, i32 -16, i32 -16>
82 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <4 x i32> %a, <i32 -16
85 define <2 x i32> @fun12(<2 x i32> %a) {
86 %r = sdiv <2 x i32> %a, <i32 -16, i32 -16>
88 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <2 x i32> %a, <i32 -16
91 define <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>
94 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <8 x i16> %a, <i16 32
97 define <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>
100 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <8 x i16> %a, <i16 -64
103 define <4 x i16> @fun15(<4 x i16> %a) {
104 %r = sdiv <4 x i16> %a, <i16 32, i16 32, i16 32, i16 32>
106 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <4 x i16> %a, <i16 32
109 define <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>
112 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <16 x i8> %a, <i8 64
115 define <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>
118 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <16 x i8> %a, <i8 -128
121 define <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>
124 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = sdiv <8 x i8> %a, <i8 -128
129 define i64 @fun19(i64 %a) {
132 ; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv i64 %a, 2
135 define i32 @fun20(i32 %a) {
138 ; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv i32 %a, 8
141 define i16 @fun21(i16 %a) {
144 ; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv i16 %a, 32
147 define i8 @fun22(i8 %a) {
150 ; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv i8 %a, -128
155 define <2 x i64> @fun23(<2 x i64> %a) {
156 %r = udiv <2 x i64> %a, <i64 2, i64 2>
158 ; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv <2 x i64> %a, <i64 2
161 define <4 x i32> @fun24(<4 x i32> %a) {
162 %r = udiv <4 x i32> %a, <i32 8, i32 8, i32 8, i32 8>
164 ; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv <4 x i32> %a, <i32 8
167 define <2 x i32> @fun25(<2 x i32> %a) {
168 %r = udiv <2 x i32> %a, <i32 8, i32 8>
170 ; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv <2 x i32> %a, <i32 8
173 define <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>
176 ; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv <8 x i16> %a, <i16 32
179 define <4 x i16> @fun27(<4 x i16> %a) {
180 %r = udiv <4 x i16> %a, <i16 32, i16 32, i16 32, i16 32>
182 ; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv <4 x i16> %a, <i16 32
185 define <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>
188 ; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv <16 x i8> %a, <i8 -128
191 define <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>
194 ; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = udiv <8 x i8> %a, <i8 -128
199 define i64 @fun30(i64 %a) {
202 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem i64 %a, 2
205 define i64 @fun31(i64 %a) {
208 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem i64 %a, -4
211 define i32 @fun32(i32 %a) {
214 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem i32 %a, 8
217 define i32 @fun33(i32 %a) {
218 %r = srem i32 %a, -16
220 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem i32 %a, -16
223 define i16 @fun34(i16 %a) {
226 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem i16 %a, 32
229 define i16 @fun35(i16 %a) {
230 %r = srem i16 %a, -64
232 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem i16 %a, -64
235 define i8 @fun36(i8 %a) {
238 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem i8 %a, 64
241 define i8 @fun37(i8 %a) {
242 %r = srem i8 %a, -128
244 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem i8 %a, -128
249 define <2 x i64> @fun38(<2 x i64> %a) {
250 %r = srem <2 x i64> %a, <i64 2, i64 2>
252 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem <2 x i64> %a, <i64 2, i64 2>
255 define <2 x i64> @fun39(<2 x i64> %a) {
256 %r = srem <2 x i64> %a, <i64 -4, i64 -4>
258 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem <2 x i64> %a, <i64 -4, i64 -4>
261 define <4 x i32> @fun40(<4 x i32> %a) {
262 %r = srem <4 x i32> %a, <i32 8, i32 8, i32 8, i32 8>
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>
267 define <4 x i32> @fun41(<4 x i32> %a) {
268 %r = srem <4 x i32> %a, <i32 -16, i32 -16, i32 -16, i32 -16>
270 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem <4 x i32> %a, <i32 -16
273 define <2 x i32> @fun42(<2 x i32> %a) {
274 %r = srem <2 x i32> %a, <i32 -16, i32 -16>
276 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem <2 x i32> %a, <i32 -16
279 define <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>
282 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem <8 x i16> %a, <i16 32
285 define <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>
288 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem <8 x i16> %a, <i16 -64
291 define <4 x i16> @fun45(<4 x i16> %a) {
292 %r = srem <4 x i16> %a, <i16 32, i16 32, i16 32, i16 32>
294 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem <4 x i16> %a, <i16 32
297 define <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>
300 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem <16 x i8> %a, <i8 64
303 define <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>
306 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem <16 x i8> %a, <i8 -128
309 define <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>
312 ; COST: Cost Model: Found an estimated cost of 4 for instruction: %r = srem <8 x i8> %a, <i8 -128
317 define i64 @fun49(i64 %a) {
320 ; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = urem i64 %a, 2
323 define i32 @fun50(i32 %a) {
326 ; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = urem i32 %a, 8
329 define i16 @fun51(i16 %a) {
332 ; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = urem i16 %a, 32
335 define i8 @fun52(i8 %a) {
338 ; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = urem i8 %a, -128
343 define <2 x i64> @fun53(<2 x i64> %a) {
344 %r = urem <2 x i64> %a, <i64 2, i64 2>
346 ; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = urem <2 x i64> %a, <i64 2
349 define <4 x i32> @fun54(<4 x i32> %a) {
350 %r = urem <4 x i32> %a, <i32 8, i32 8, i32 8, i32 8>
352 ; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = urem <4 x i32> %a, <i32 8
355 define <2 x i32> @fun55(<2 x i32> %a) {
356 %r = urem <2 x i32> %a, <i32 8, i32 8>
358 ; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = urem <2 x i32> %a, <i32 8
361 define <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>
364 ; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = urem <8 x i16> %a, <i16 32
367 define <4 x i16> @fun57(<4 x i16> %a) {
368 %r = urem <4 x i16> %a, <i16 32, i16 32, i16 32, i16 32>
370 ; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = urem <4 x i16> %a, <i16 32
373 define <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>
376 ; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = urem <16 x i8> %a, <i8 -128
379 define <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>
382 ; COST: Cost Model: Found an estimated cost of 1 for instruction: %r = urem <8 x i8> %a, <i8 -128