1 ; RUN: opt < %s -cost-model -analyze -mtriple=systemz-unknown -mcpu=z13 \
2 ; RUN: | FileCheck %s -check-prefixes=CHECK,Z13
3 ; RUN: opt < %s -cost-model -analyze -mtriple=systemz-unknown -mcpu=z15 \
4 ; RUN: | FileCheck %s -check-prefixes=CHECK,Z15
6 define void @bswap_i64(i64 %arg, <2 x i64> %arg2) {
7 ; CHECK: Printing analysis 'Cost Model Analysis' for function 'bswap_i64':
8 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp1 = tail call i64
9 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp2 = tail call <2 x i64>
10 ; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %swp4 = tail call <4 x i64>
11 %swp1 = tail call i64 @llvm.bswap.i64(i64 %arg)
12 %swp2 = tail call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %arg2)
13 %swp4 = tail call <4 x i64> @llvm.bswap.v4i64(<4 x i64> undef)
17 define void @bswap_i32(i32 %arg, <2 x i32> %arg2, <4 x i32> %arg4) {
18 ; CHECK: Printing analysis 'Cost Model Analysis' for function 'bswap_i32':
19 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp1 = tail call i32
20 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp2 = tail call <2 x i32>
21 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp4 = tail call <4 x i32>
22 ; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %swp8 = tail call <8 x i32>
23 %swp1 = tail call i32 @llvm.bswap.i32(i32 %arg)
24 %swp2 = tail call <2 x i32> @llvm.bswap.v2i32(<2 x i32> %arg2)
25 %swp4 = tail call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %arg4)
26 %swp8 = tail call <8 x i32> @llvm.bswap.v8i32(<8 x i32> undef)
30 define void @bswap_i16(i16 %arg, <2 x i16> %arg2, <4 x i16> %arg4,
32 ; CHECK: Printing analysis 'Cost Model Analysis' for function 'bswap_i16':
33 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp1 = tail call i16 @llvm.bswap.i16(i16 %arg)
34 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp2 = tail call <2 x i16> @llvm.bswap.v2i16(<2 x i16> %arg2)
35 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp4 = tail call <4 x i16> @llvm.bswap.v4i16(<4 x i16> %arg4)
36 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp8 = tail call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %arg8)
37 ; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %swp16 = tail call <16 x i16> @llvm.bswap.v16i16(<16 x i16> undef)
38 %swp1 = tail call i16 @llvm.bswap.i16(i16 %arg)
39 %swp2 = tail call <2 x i16> @llvm.bswap.v2i16(<2 x i16> %arg2)
40 %swp4 = tail call <4 x i16> @llvm.bswap.v4i16(<4 x i16> %arg4)
41 %swp8 = tail call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %arg8)
42 %swp16 = tail call <16 x i16> @llvm.bswap.v16i16(<16 x i16> undef)
46 ; Test that store/load reversed is reflected in costs.
47 define void @bswap_i64_mem(i64* %src, i64 %arg, i64* %dst) {
48 ; CHECK: Printing analysis 'Cost Model Analysis' for function 'bswap_i64_mem':
49 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: %Ld1 = load i64, i64* %src
50 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp1 = tail call i64 @llvm.bswap.i64(i64 %Ld1)
51 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp2 = tail call i64 @llvm.bswap.i64(i64 %arg)
52 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: store i64 %swp2, i64* %dst
53 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %Ld2 = load i64, i64* %src
54 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp3 = tail call i64 @llvm.bswap.i64(i64 %Ld2)
55 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: store i64 %swp3, i64* %dst
56 %Ld1 = load i64, i64* %src
57 %swp1 = tail call i64 @llvm.bswap.i64(i64 %Ld1)
59 %swp2 = tail call i64 @llvm.bswap.i64(i64 %arg)
60 store i64 %swp2, i64* %dst
62 %Ld2 = load i64, i64* %src
63 %swp3 = tail call i64 @llvm.bswap.i64(i64 %Ld2)
64 store i64 %swp3, i64* %dst
69 define void @bswap_v2i64_mem(<2 x i64>* %src, <2 x i64> %arg, <2 x i64>* %dst) {
70 ; CHECK:Printing analysis 'Cost Model Analysis' for function 'bswap_v2i64_mem':
71 ; Z13: Cost Model: Found an estimated cost of 1 for instruction: %Ld1 = load <2 x i64>, <2 x i64>* %src
72 ; Z15: Cost Model: Found an estimated cost of 0 for instruction: %Ld1 = load <2 x i64>, <2 x i64>* %src
73 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp1 = tail call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %Ld1)
74 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp2 = tail call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %arg)
75 ; Z13: Cost Model: Found an estimated cost of 1 for instruction: store <2 x i64> %swp2, <2 x i64>* %dst
76 ; Z15: Cost Model: Found an estimated cost of 0 for instruction: store <2 x i64> %swp2, <2 x i64>* %dst
77 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %Ld2 = load <2 x i64>, <2 x i64>* %src
78 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp3 = tail call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %Ld2)
79 ; Z13: Cost Model: Found an estimated cost of 1 for instruction: store <2 x i64> %swp3, <2 x i64>* %dst
80 ; Z15: Cost Model: Found an estimated cost of 0 for instruction: store <2 x i64> %swp3, <2 x i64>* %dst
82 %Ld1 = load <2 x i64>, <2 x i64>* %src
83 %swp1 = tail call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %Ld1)
85 %swp2 = tail call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %arg)
86 store <2 x i64> %swp2, <2 x i64>* %dst
88 %Ld2 = load <2 x i64>, <2 x i64>* %src
89 %swp3 = tail call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %Ld2)
90 store <2 x i64> %swp3, <2 x i64>* %dst
95 define void @bswap_i32_mem(i32* %src, i32 %arg, i32* %dst) {
96 ; CHECK: Printing analysis 'Cost Model Analysis' for function 'bswap_i32_mem':
97 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: %Ld1 = load i32, i32* %src
98 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp1 = tail call i32 @llvm.bswap.i32(i32 %Ld1)
99 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp2 = tail call i32 @llvm.bswap.i32(i32 %arg)
100 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: store i32 %swp2, i32* %dst
101 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %Ld2 = load i32, i32* %src
102 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp3 = tail call i32 @llvm.bswap.i32(i32 %Ld2)
103 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: store i32 %swp3, i32* %dst
104 %Ld1 = load i32, i32* %src
105 %swp1 = tail call i32 @llvm.bswap.i32(i32 %Ld1)
107 %swp2 = tail call i32 @llvm.bswap.i32(i32 %arg)
108 store i32 %swp2, i32* %dst
110 %Ld2 = load i32, i32* %src
111 %swp3 = tail call i32 @llvm.bswap.i32(i32 %Ld2)
112 store i32 %swp3, i32* %dst
117 define void @bswap_v4i32_mem(<4 x i32>* %src, <4 x i32> %arg, <4 x i32>* %dst) {
118 ; CHECK: Printing analysis 'Cost Model Analysis' for function 'bswap_v4i32_mem':
119 ; Z13: Cost Model: Found an estimated cost of 1 for instruction: %Ld1 = load <4 x i32>, <4 x i32>* %src
120 ; Z15: Cost Model: Found an estimated cost of 0 for instruction: %Ld1 = load <4 x i32>, <4 x i32>* %src
121 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp1 = tail call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %Ld1)
122 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp2 = tail call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %arg)
123 ; Z13: Cost Model: Found an estimated cost of 1 for instruction: store <4 x i32> %swp2, <4 x i32>* %dst
124 ; Z15: Cost Model: Found an estimated cost of 0 for instruction: store <4 x i32> %swp2, <4 x i32>* %dst
125 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %Ld2 = load <4 x i32>, <4 x i32>* %src
126 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp3 = tail call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %Ld2)
127 ; Z13: Cost Model: Found an estimated cost of 1 for instruction: store <4 x i32> %swp3, <4 x i32>* %dst
128 ; Z15: Cost Model: Found an estimated cost of 0 for instruction: store <4 x i32> %swp3, <4 x i32>* %dst
129 %Ld1 = load <4 x i32>, <4 x i32>* %src
130 %swp1 = tail call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %Ld1)
132 %swp2 = tail call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %arg)
133 store <4 x i32> %swp2, <4 x i32>* %dst
135 %Ld2 = load <4 x i32>, <4 x i32>* %src
136 %swp3 = tail call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %Ld2)
137 store <4 x i32> %swp3, <4 x i32>* %dst
142 define void @bswap_i16_mem(i16* %src, i16 %arg, i16* %dst) {
143 ; CHECK: Printing analysis 'Cost Model Analysis' for function 'bswap_i16_mem':
144 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: %Ld1 = load i16, i16* %src
145 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp1 = tail call i16 @llvm.bswap.i16(i16 %Ld1)
146 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp2 = tail call i16 @llvm.bswap.i16(i16 %arg)
147 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: store i16 %swp2, i16* %dst
148 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %Ld2 = load i16, i16* %src
149 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp3 = tail call i16 @llvm.bswap.i16(i16 %Ld2)
150 ; CHECK: Cost Model: Found an estimated cost of 0 for instruction: store i16 %swp3, i16* %dst
151 %Ld1 = load i16, i16* %src
152 %swp1 = tail call i16 @llvm.bswap.i16(i16 %Ld1)
154 %swp2 = tail call i16 @llvm.bswap.i16(i16 %arg)
155 store i16 %swp2, i16* %dst
157 %Ld2 = load i16, i16* %src
158 %swp3 = tail call i16 @llvm.bswap.i16(i16 %Ld2)
159 store i16 %swp3, i16* %dst
164 define void @bswap_v8i16_mem(<8 x i16>* %src, <8 x i16> %arg, <8 x i16>* %dst) {
165 ; CHECK: Printing analysis 'Cost Model Analysis' for function 'bswap_v8i16_mem':
166 ; Z13: Cost Model: Found an estimated cost of 1 for instruction: %Ld1 = load <8 x i16>, <8 x i16>* %src
167 ; Z15: Cost Model: Found an estimated cost of 0 for instruction: %Ld1 = load <8 x i16>, <8 x i16>* %src
168 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp1 = tail call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %Ld1)
169 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp2 = tail call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %arg)
170 ; Z13: Cost Model: Found an estimated cost of 1 for instruction: store <8 x i16> %swp2, <8 x i16>* %dst
171 ; Z15: Cost Model: Found an estimated cost of 0 for instruction: store <8 x i16> %swp2, <8 x i16>* %dst
172 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %Ld2 = load <8 x i16>, <8 x i16>* %src
173 ; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %swp3 = tail call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %Ld2)
174 ; Z13: Cost Model: Found an estimated cost of 1 for instruction: store <8 x i16> %swp3, <8 x i16>* %dst
175 ; Z15: Cost Model: Found an estimated cost of 0 for instruction: store <8 x i16> %swp3, <8 x i16>* %dst
176 %Ld1 = load <8 x i16>, <8 x i16>* %src
177 %swp1 = tail call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %Ld1)
179 %swp2 = tail call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %arg)
180 store <8 x i16> %swp2, <8 x i16>* %dst
182 %Ld2 = load <8 x i16>, <8 x i16>* %src
183 %swp3 = tail call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %Ld2)
184 store <8 x i16> %swp3, <8 x i16>* %dst
189 declare i64 @llvm.bswap.i64(i64)
190 declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
191 declare <4 x i64> @llvm.bswap.v4i64(<4 x i64>)
193 declare i32 @llvm.bswap.i32(i32)
194 declare <2 x i32> @llvm.bswap.v2i32(<2 x i32>)
195 declare <4 x i32> @llvm.bswap.v4i32(<4 x i32>)
196 declare <8 x i32> @llvm.bswap.v8i32(<8 x i32>)
198 declare i16 @llvm.bswap.i16(i16)
199 declare <2 x i16> @llvm.bswap.v2i16(<2 x i16>)
200 declare <4 x i16> @llvm.bswap.v4i16(<4 x i16>)
201 declare <8 x i16> @llvm.bswap.v8i16(<8 x i16>)
202 declare <16 x i16> @llvm.bswap.v16i16(<16 x i16>)