1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2 ; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes="print<cost-model>" 2>&1 -disable-output | FileCheck %s --check-prefixes=ALL,X64
3 ; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes="print<cost-model>" 2>&1 -disable-output -mattr=+movbe | FileCheck %s --check-prefixes=ALL,X64-MOVBE
4 ; RUN: opt < %s -mtriple=x86_64-unknown-linux-gnu -passes="print<cost-model>" 2>&1 -disable-output -mattr=+movbe,+fast-movbe | FileCheck %s --check-prefixes=ALL,X64-FASTMOVBE
6 ; RUN: opt < %s -mtriple=i686-unknown-linux-gnu -passes="print<cost-model>" 2>&1 -disable-output | FileCheck %s --check-prefixes=ALL,X32
7 ; RUN: opt < %s -mtriple=i686-unknown-linux-gnu -passes="print<cost-model>" 2>&1 -disable-output -mattr=+movbe | FileCheck %s --check-prefixes=ALL,X32-MOVBE
8 ; RUN: opt < %s -mtriple=i686-unknown-linux-gnu -passes="print<cost-model>" 2>&1 -disable-output -mattr=+movbe,+fast-movbe | FileCheck %s --check-prefixes=ALL,X32-FASTMOVBE
10 declare i16 @llvm.bswap.i16(i16)
11 declare i32 @llvm.bswap.i32(i32)
12 declare i64 @llvm.bswap.i64(i64)
13 declare i128 @llvm.bswap.i128(i128)
15 define void @var_bswap_store_i16(i16 %a, ptr %dst) {
16 ; X64-LABEL: 'var_bswap_store_i16'
17 ; X64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i16 @llvm.bswap.i16(i16 %a)
18 ; X64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i16 %bswap, ptr %dst, align 1
19 ; X64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
21 ; X64-MOVBE-LABEL: 'var_bswap_store_i16'
22 ; X64-MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i16 @llvm.bswap.i16(i16 %a)
23 ; X64-MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i16 %bswap, ptr %dst, align 1
24 ; X64-MOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
26 ; X64-FASTMOVBE-LABEL: 'var_bswap_store_i16'
27 ; X64-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %bswap = call i16 @llvm.bswap.i16(i16 %a)
28 ; X64-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i16 %bswap, ptr %dst, align 1
29 ; X64-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
31 ; X32-LABEL: 'var_bswap_store_i16'
32 ; X32-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i16 @llvm.bswap.i16(i16 %a)
33 ; X32-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i16 %bswap, ptr %dst, align 1
34 ; X32-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
36 ; X32-MOVBE-LABEL: 'var_bswap_store_i16'
37 ; X32-MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i16 @llvm.bswap.i16(i16 %a)
38 ; X32-MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i16 %bswap, ptr %dst, align 1
39 ; X32-MOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
41 ; X32-FASTMOVBE-LABEL: 'var_bswap_store_i16'
42 ; X32-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %bswap = call i16 @llvm.bswap.i16(i16 %a)
43 ; X32-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i16 %bswap, ptr %dst, align 1
44 ; X32-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
46 %bswap = call i16 @llvm.bswap.i16(i16 %a)
47 store i16 %bswap, ptr %dst, align 1
51 define void @var_bswap_store_i16_extrause(i16 %a, ptr %dst) {
52 ; ALL-LABEL: 'var_bswap_store_i16_extrause'
53 ; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i16 @llvm.bswap.i16(i16 %a)
54 ; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i16 %bswap, ptr %dst, align 1
55 ; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap2 = shl i16 %bswap, 2
56 ; ALL-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
58 %bswap = call i16 @llvm.bswap.i16(i16 %a)
59 store i16 %bswap, ptr %dst, align 1
61 %bswap2 = shl i16 %bswap, 2 ; incur an extra use to the bswap
66 define void @var_bswap_store_i32(i32 %a, ptr %dst) {
67 ; X64-LABEL: 'var_bswap_store_i32'
68 ; X64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i32 @llvm.bswap.i32(i32 %a)
69 ; X64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i32 %bswap, ptr %dst, align 1
70 ; X64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
72 ; X64-MOVBE-LABEL: 'var_bswap_store_i32'
73 ; X64-MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i32 @llvm.bswap.i32(i32 %a)
74 ; X64-MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i32 %bswap, ptr %dst, align 1
75 ; X64-MOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
77 ; X64-FASTMOVBE-LABEL: 'var_bswap_store_i32'
78 ; X64-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %bswap = call i32 @llvm.bswap.i32(i32 %a)
79 ; X64-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i32 %bswap, ptr %dst, align 1
80 ; X64-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
82 ; X32-LABEL: 'var_bswap_store_i32'
83 ; X32-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i32 @llvm.bswap.i32(i32 %a)
84 ; X32-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i32 %bswap, ptr %dst, align 1
85 ; X32-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
87 ; X32-MOVBE-LABEL: 'var_bswap_store_i32'
88 ; X32-MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i32 @llvm.bswap.i32(i32 %a)
89 ; X32-MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i32 %bswap, ptr %dst, align 1
90 ; X32-MOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
92 ; X32-FASTMOVBE-LABEL: 'var_bswap_store_i32'
93 ; X32-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %bswap = call i32 @llvm.bswap.i32(i32 %a)
94 ; X32-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i32 %bswap, ptr %dst, align 1
95 ; X32-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
97 %bswap = call i32 @llvm.bswap.i32(i32 %a)
98 store i32 %bswap, ptr %dst, align 1
102 define void @var_bswap_store_i32_extrause(i32 %a, ptr %dst) {
103 ; ALL-LABEL: 'var_bswap_store_i32_extrause'
104 ; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i32 @llvm.bswap.i32(i32 %a)
105 ; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i32 %bswap, ptr %dst, align 1
106 ; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap2 = shl i32 %bswap, 2
107 ; ALL-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
109 %bswap = call i32 @llvm.bswap.i32(i32 %a)
110 store i32 %bswap, ptr %dst, align 1
112 %bswap2 = shl i32 %bswap, 2 ; incur an extra use to the bswap
117 define void @var_bswap_store_i64(i64 %a, ptr %dst) {
118 ; X64-LABEL: 'var_bswap_store_i64'
119 ; X64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i64 @llvm.bswap.i64(i64 %a)
120 ; X64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i64 %bswap, ptr %dst, align 1
121 ; X64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
123 ; X64-MOVBE-LABEL: 'var_bswap_store_i64'
124 ; X64-MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i64 @llvm.bswap.i64(i64 %a)
125 ; X64-MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i64 %bswap, ptr %dst, align 1
126 ; X64-MOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
128 ; X64-FASTMOVBE-LABEL: 'var_bswap_store_i64'
129 ; X64-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %bswap = call i64 @llvm.bswap.i64(i64 %a)
130 ; X64-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i64 %bswap, ptr %dst, align 1
131 ; X64-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
133 ; X32-LABEL: 'var_bswap_store_i64'
134 ; X32-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap = call i64 @llvm.bswap.i64(i64 %a)
135 ; X32-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store i64 %bswap, ptr %dst, align 1
136 ; X32-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
138 ; X32-MOVBE-LABEL: 'var_bswap_store_i64'
139 ; X32-MOVBE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap = call i64 @llvm.bswap.i64(i64 %a)
140 ; X32-MOVBE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store i64 %bswap, ptr %dst, align 1
141 ; X32-MOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
143 ; X32-FASTMOVBE-LABEL: 'var_bswap_store_i64'
144 ; X32-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %bswap = call i64 @llvm.bswap.i64(i64 %a)
145 ; X32-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store i64 %bswap, ptr %dst, align 1
146 ; X32-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
148 %bswap = call i64 @llvm.bswap.i64(i64 %a)
149 store i64 %bswap, ptr %dst, align 1
153 define void @var_bswap_store_i64_extrause(i64 %a, ptr %dst) {
154 ; X64-LABEL: 'var_bswap_store_i64_extrause'
155 ; X64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i64 @llvm.bswap.i64(i64 %a)
156 ; X64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i64 %bswap, ptr %dst, align 1
157 ; X64-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap2 = shl i64 %bswap, 2
158 ; X64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
160 ; X64-MOVBE-LABEL: 'var_bswap_store_i64_extrause'
161 ; X64-MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i64 @llvm.bswap.i64(i64 %a)
162 ; X64-MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i64 %bswap, ptr %dst, align 1
163 ; X64-MOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap2 = shl i64 %bswap, 2
164 ; X64-MOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
166 ; X64-FASTMOVBE-LABEL: 'var_bswap_store_i64_extrause'
167 ; X64-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap = call i64 @llvm.bswap.i64(i64 %a)
168 ; X64-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i64 %bswap, ptr %dst, align 1
169 ; X64-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %bswap2 = shl i64 %bswap, 2
170 ; X64-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
172 ; X32-LABEL: 'var_bswap_store_i64_extrause'
173 ; X32-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap = call i64 @llvm.bswap.i64(i64 %a)
174 ; X32-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store i64 %bswap, ptr %dst, align 1
175 ; X32-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap2 = shl i64 %bswap, 2
176 ; X32-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
178 ; X32-MOVBE-LABEL: 'var_bswap_store_i64_extrause'
179 ; X32-MOVBE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap = call i64 @llvm.bswap.i64(i64 %a)
180 ; X32-MOVBE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store i64 %bswap, ptr %dst, align 1
181 ; X32-MOVBE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap2 = shl i64 %bswap, 2
182 ; X32-MOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
184 ; X32-FASTMOVBE-LABEL: 'var_bswap_store_i64_extrause'
185 ; X32-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap = call i64 @llvm.bswap.i64(i64 %a)
186 ; X32-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store i64 %bswap, ptr %dst, align 1
187 ; X32-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap2 = shl i64 %bswap, 2
188 ; X32-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
190 %bswap = call i64 @llvm.bswap.i64(i64 %a)
191 store i64 %bswap, ptr %dst, align 1
193 %bswap2 = shl i64 %bswap, 2 ; incur an extra use to the bswap
198 define void @var_bswap_store_i128(i128 %a, ptr %dst) {
199 ; X64-LABEL: 'var_bswap_store_i128'
200 ; X64-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap = call i128 @llvm.bswap.i128(i128 %a)
201 ; X64-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store i128 %bswap, ptr %dst, align 1
202 ; X64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
204 ; X64-MOVBE-LABEL: 'var_bswap_store_i128'
205 ; X64-MOVBE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap = call i128 @llvm.bswap.i128(i128 %a)
206 ; X64-MOVBE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store i128 %bswap, ptr %dst, align 1
207 ; X64-MOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
209 ; X64-FASTMOVBE-LABEL: 'var_bswap_store_i128'
210 ; X64-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %bswap = call i128 @llvm.bswap.i128(i128 %a)
211 ; X64-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store i128 %bswap, ptr %dst, align 1
212 ; X64-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
214 ; X32-LABEL: 'var_bswap_store_i128'
215 ; X32-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap = call i128 @llvm.bswap.i128(i128 %a)
216 ; X32-NEXT: Cost Model: Found an estimated cost of 4 for instruction: store i128 %bswap, ptr %dst, align 1
217 ; X32-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
219 ; X32-MOVBE-LABEL: 'var_bswap_store_i128'
220 ; X32-MOVBE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap = call i128 @llvm.bswap.i128(i128 %a)
221 ; X32-MOVBE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: store i128 %bswap, ptr %dst, align 1
222 ; X32-MOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
224 ; X32-FASTMOVBE-LABEL: 'var_bswap_store_i128'
225 ; X32-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %bswap = call i128 @llvm.bswap.i128(i128 %a)
226 ; X32-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: store i128 %bswap, ptr %dst, align 1
227 ; X32-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
229 %bswap = call i128 @llvm.bswap.i128(i128 %a)
230 store i128 %bswap, ptr %dst, align 1
234 define void @var_bswap_store_i128_extrause(i128 %a, ptr %dst) {
235 ; X64-LABEL: 'var_bswap_store_i128_extrause'
236 ; X64-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap = call i128 @llvm.bswap.i128(i128 %a)
237 ; X64-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store i128 %bswap, ptr %dst, align 1
238 ; X64-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap2 = shl i128 %bswap, 2
239 ; X64-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
241 ; X64-MOVBE-LABEL: 'var_bswap_store_i128_extrause'
242 ; X64-MOVBE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap = call i128 @llvm.bswap.i128(i128 %a)
243 ; X64-MOVBE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store i128 %bswap, ptr %dst, align 1
244 ; X64-MOVBE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap2 = shl i128 %bswap, 2
245 ; X64-MOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
247 ; X64-FASTMOVBE-LABEL: 'var_bswap_store_i128_extrause'
248 ; X64-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap = call i128 @llvm.bswap.i128(i128 %a)
249 ; X64-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: store i128 %bswap, ptr %dst, align 1
250 ; X64-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %bswap2 = shl i128 %bswap, 2
251 ; X64-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
253 ; X32-LABEL: 'var_bswap_store_i128_extrause'
254 ; X32-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap = call i128 @llvm.bswap.i128(i128 %a)
255 ; X32-NEXT: Cost Model: Found an estimated cost of 4 for instruction: store i128 %bswap, ptr %dst, align 1
256 ; X32-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap2 = shl i128 %bswap, 2
257 ; X32-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
259 ; X32-MOVBE-LABEL: 'var_bswap_store_i128_extrause'
260 ; X32-MOVBE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap = call i128 @llvm.bswap.i128(i128 %a)
261 ; X32-MOVBE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: store i128 %bswap, ptr %dst, align 1
262 ; X32-MOVBE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap2 = shl i128 %bswap, 2
263 ; X32-MOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
265 ; X32-FASTMOVBE-LABEL: 'var_bswap_store_i128_extrause'
266 ; X32-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap = call i128 @llvm.bswap.i128(i128 %a)
267 ; X32-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: store i128 %bswap, ptr %dst, align 1
268 ; X32-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %bswap2 = shl i128 %bswap, 2
269 ; X32-FASTMOVBE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
271 %bswap = call i128 @llvm.bswap.i128(i128 %a)
272 store i128 %bswap, ptr %dst, align 1
274 %bswap2 = shl i128 %bswap, 2 ; incur an extra use to the bswap