1 ; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output -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
9 ; Check costs of divisions/remainders by a vector of constants that is *not*
10 ; a power of two. A sequence containing a multiply and shifts will replace
11 ; the divide instruction.
15 define i64 @fun0(i64 %a) {
18 ; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = sdiv i64 %a, 20
21 define i32 @fun1(i32 %a) {
24 ; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = sdiv i32 %a, 20
27 define i16 @fun2(i16 %a) {
30 ; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = sdiv i16 %a, 20
33 define i8 @fun3(i8 %a) {
36 ; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = sdiv i8 %a, 20
41 define <2 x i64> @fun4(<2 x i64> %a) {
42 %r = sdiv <2 x i64> %a, <i64 20, i64 21>
44 ; COST: Cost Model: Found an estimated cost of 24 for instruction: %r = sdiv <2 x i64>
47 define <4 x i32> @fun5(<4 x i32> %a) {
48 %r = sdiv <4 x i32> %a, <i32 20, i32 20, i32 20, i32 20>
50 ; COST: Cost Model: Found an estimated cost of 49 for instruction: %r = sdiv <4 x i32>
53 define <2 x i32> @fun6(<2 x i32> %a) {
54 %r = sdiv <2 x i32> %a, <i32 20, i32 21>
56 ; COST: Cost Model: Found an estimated cost of 25 for instruction: %r = sdiv <2 x i32>
59 define <8 x i16> @fun7(<8 x i16> %a) {
60 %r = sdiv <8 x i16> %a, <i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 20>
62 ; COST: Cost Model: Found an estimated cost of 97 for instruction: %r = sdiv <8 x i16>
65 define <4 x i16> @fun8(<4 x i16> %a) {
66 %r = sdiv <4 x i16> %a, <i16 20, i16 20, i16 20, i16 21>
68 ; COST: Cost Model: Found an estimated cost of 49 for instruction: %r = sdiv <4 x i16>
71 define <16 x i8> @fun9(<16 x i8> %a) {
72 %r = sdiv <16 x i8> %a, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20>
74 ; COST: Cost Model: Found an estimated cost of 193 for instruction: %r = sdiv <16 x i8>
77 define <8 x i8> @fun10(<8 x i8> %a) {
78 %r = sdiv <8 x i8> %a, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 21>
80 ; COST: Cost Model: Found an estimated cost of 97 for instruction: %r = sdiv <8 x i8>
85 define i64 @fun11(i64 %a) {
88 ; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = udiv i64 %a, 20
91 define i32 @fun12(i32 %a) {
94 ; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = udiv i32 %a, 20
97 define i16 @fun13(i16 %a) {
100 ; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = udiv i16 %a, 20
103 define i8 @fun14(i8 %a) {
106 ; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = udiv i8
111 define <2 x i64> @fun15(<2 x i64> %a) {
112 %r = udiv <2 x i64> %a, <i64 20, i64 20>
114 ; COST: Cost Model: Found an estimated cost of 24 for instruction: %r = udiv <2 x i64>
117 define <4 x i32> @fun16(<4 x i32> %a) {
118 %r = udiv <4 x i32> %a, <i32 20, i32 20, i32 20, i32 21>
120 ; COST: Cost Model: Found an estimated cost of 49 for instruction: %r = udiv <4 x i32>
123 define <2 x i32> @fun17(<2 x i32> %a) {
124 %r = udiv <2 x i32> %a, <i32 20, i32 20>
126 ; COST: Cost Model: Found an estimated cost of 25 for instruction: %r = udiv <2 x i32>
129 define <8 x i16> @fun18(<8 x i16> %a) {
130 %r = udiv <8 x i16> %a, <i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 21>
132 ; COST: Cost Model: Found an estimated cost of 97 for instruction: %r = udiv <8 x i16>
135 define <4 x i16> @fun19(<4 x i16> %a) {
136 %r = udiv <4 x i16> %a, <i16 20, i16 20, i16 20, i16 20>
138 ; COST: Cost Model: Found an estimated cost of 49 for instruction: %r = udiv <4 x i16>
141 define <16 x i8> @fun20(<16 x i8> %a) {
142 %r = udiv <16 x i8> %a, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 21>
144 ; COST: Cost Model: Found an estimated cost of 193 for instruction: %r = udiv <16 x i8>
147 define <8 x i8> @fun21(<8 x i8> %a) {
148 %r = udiv <8 x i8> %a, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20>
150 ; COST: Cost Model: Found an estimated cost of 97 for instruction: %r = udiv <8 x i8>
155 define i64 @fun22(i64 %a) {
158 ; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = srem i64
161 define i32 @fun23(i32 %a) {
164 ; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = srem i32
167 define i16 @fun24(i16 %a) {
170 ; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = srem i16
173 define i8 @fun25(i8 %a) {
176 ; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = srem i8
181 define <2 x i64> @fun26(<2 x i64> %a) {
182 %r = srem <2 x i64> %a, <i64 20, i64 21>
184 ; COST: Cost Model: Found an estimated cost of 24 for instruction: %r = srem <2 x i64>
187 define <4 x i32> @fun27(<4 x i32> %a) {
188 %r = srem <4 x i32> %a, <i32 20, i32 20, i32 20, i32 20>
190 ; COST: Cost Model: Found an estimated cost of 49 for instruction: %r = srem <4 x i32>
193 define <2 x i32> @fun28(<2 x i32> %a) {
194 %r = srem <2 x i32> %a, <i32 20, i32 21>
196 ; COST: Cost Model: Found an estimated cost of 25 for instruction: %r = srem <2 x i32>
199 define <8 x i16> @fun29(<8 x i16> %a) {
200 %r = srem <8 x i16> %a, <i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 20>
202 ; COST: Cost Model: Found an estimated cost of 97 for instruction: %r = srem <8 x i16>
205 define <4 x i16> @fun30(<4 x i16> %a) {
206 %r = srem <4 x i16> %a, <i16 20, i16 20, i16 20, i16 21>
208 ; COST: Cost Model: Found an estimated cost of 49 for instruction: %r = srem <4 x i16>
211 define <16 x i8> @fun31(<16 x i8> %a) {
212 %r = srem <16 x i8> %a, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20>
214 ; COST: Cost Model: Found an estimated cost of 193 for instruction: %r = srem <16 x i8>
217 define <8 x i8> @fun32(<8 x i8> %a) {
218 %r = srem <8 x i8> %a, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 21>
220 ; COST: Cost Model: Found an estimated cost of 97 for instruction: %r = srem <8 x i8>
225 define i64 @fun33(i64 %a) {
228 ; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = urem i64
231 define i32 @fun34(i32 %a) {
234 ; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = urem i32
237 define i16 @fun35(i16 %a) {
240 ; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = urem i16
243 define i8 @fun36(i8 %a) {
246 ; COST: Cost Model: Found an estimated cost of 10 for instruction: %r = urem i8
251 define <2 x i64> @fun37(<2 x i64> %a) {
252 %r = urem <2 x i64> %a, <i64 20, i64 20>
254 ; COST: Cost Model: Found an estimated cost of 24 for instruction: %r = urem <2 x i64>
257 define <4 x i32> @fun38(<4 x i32> %a) {
258 %r = urem <4 x i32> %a, <i32 20, i32 20, i32 20, i32 21>
260 ; COST: Cost Model: Found an estimated cost of 49 for instruction: %r = urem <4 x i32>
263 define <2 x i32> @fun39(<2 x i32> %a) {
264 %r = urem <2 x i32> %a, <i32 20, i32 20>
266 ; COST: Cost Model: Found an estimated cost of 25 for instruction: %r = urem <2 x i32>
269 define <8 x i16> @fun40(<8 x i16> %a) {
270 %r = urem <8 x i16> %a, <i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 20, i16 21>
272 ; COST: Cost Model: Found an estimated cost of 97 for instruction: %r = urem <8 x i16>
275 define <4 x i16> @fun41(<4 x i16> %a) {
276 %r = urem <4 x i16> %a, <i16 20, i16 20, i16 20, i16 20>
278 ; COST: Cost Model: Found an estimated cost of 49 for instruction: %r = urem <4 x i16>
281 define <16 x i8> @fun42(<16 x i8> %a) {
282 %r = urem <16 x i8> %a, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 21>
284 ; COST: Cost Model: Found an estimated cost of 193 for instruction: %r = urem <16 x i8>
287 define <8 x i8> @fun43(<8 x i8> %a) {
288 %r = urem <8 x i8> %a, <i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20, i8 20>
290 ; COST: Cost Model: Found an estimated cost of 97 for instruction: %r = urem <8 x i8>