Mercurial > hg > CbC > CbC_llvm
comparison test/Transforms/InstCombine/double-float-shrink-2.ll @ 121:803732b1fca8
LLVM 5.0
author | kono |
---|---|
date | Fri, 27 Oct 2017 17:07:41 +0900 |
parents | 95c75e76d11b |
children | c2174574ed3a |
comparison
equal
deleted
inserted
replaced
120:1172e4bd9c6f | 121:803732b1fca8 |
---|---|
1 ; RUN: opt < %s -instcombine -S -mtriple "i386-pc-linux" | FileCheck -check-prefix=DO-SIMPLIFY %s | 1 ; RUN: opt < %s -instcombine -S -mtriple "i386-pc-linux" | FileCheck -check-prefix=DO-SIMPLIFY -check-prefix=ALL %s |
2 ; RUN: opt < %s -instcombine -S -mtriple "i386-pc-win32" | FileCheck -check-prefix=DONT-SIMPLIFY %s | 2 ; RUN: opt < %s -instcombine -S -mtriple "i386-pc-win32" | FileCheck -check-prefix=DONT-SIMPLIFY -check-prefix=ALL %s |
3 ; RUN: opt < %s -instcombine -S -mtriple "x86_64-pc-win32" | FileCheck -check-prefix=C89-SIMPLIFY %s | 3 ; RUN: opt < %s -instcombine -S -mtriple "x86_64-pc-win32" | FileCheck -check-prefix=C89-SIMPLIFY -check-prefix=ALL %s |
4 ; RUN: opt < %s -instcombine -S -mtriple "i386-pc-mingw32" | FileCheck -check-prefix=DO-SIMPLIFY %s | 4 ; RUN: opt < %s -instcombine -S -mtriple "i386-pc-mingw32" | FileCheck -check-prefix=DO-SIMPLIFY -check-prefix=ALL %s |
5 ; RUN: opt < %s -instcombine -S -mtriple "x86_64-pc-mingw32" | FileCheck -check-prefix=DO-SIMPLIFY %s | 5 ; RUN: opt < %s -instcombine -S -mtriple "x86_64-pc-mingw32" | FileCheck -check-prefix=DO-SIMPLIFY -check-prefix=ALL %s |
6 ; RUN: opt < %s -instcombine -S -mtriple "sparc-sun-solaris" | FileCheck -check-prefix=DO-SIMPLIFY %s | 6 ; RUN: opt < %s -instcombine -S -mtriple "sparc-sun-solaris" | FileCheck -check-prefix=DO-SIMPLIFY -check-prefix=ALL %s |
7 | |
8 ; DO-SIMPLIFY: call float @floorf( | |
9 ; DO-SIMPLIFY: call float @ceilf( | |
10 ; DO-SIMPLIFY: call float @roundf( | |
11 ; DO-SIMPLIFY: call float @nearbyintf( | |
12 ; DO-SIMPLIFY: call float @truncf( | |
13 ; DO-SIMPLIFY: call float @fabsf( | |
14 | |
15 ; C89-SIMPLIFY: call float @floorf( | |
16 ; C89-SIMPLIFY: call float @ceilf( | |
17 ; C89-SIMPLIFY: call double @round( | |
18 ; C89-SIMPLIFY: call double @nearbyint( | |
19 | |
20 ; DONT-SIMPLIFY: call double @floor( | |
21 ; DONT-SIMPLIFY: call double @ceil( | |
22 ; DONT-SIMPLIFY: call double @round( | |
23 ; DONT-SIMPLIFY: call double @nearbyint( | |
24 ; DONT-SIMPLIFY: call double @trunc( | |
25 ; DONT-SIMPLIFY: call double @fabs( | |
26 | 7 |
27 declare double @floor(double) | 8 declare double @floor(double) |
28 declare double @ceil(double) | 9 declare double @ceil(double) |
29 declare double @round(double) | 10 declare double @round(double) |
30 declare double @nearbyint(double) | 11 declare double @nearbyint(double) |
31 declare double @trunc(double) | 12 declare double @trunc(double) |
32 declare double @fabs(double) | 13 declare double @fabs(double) |
33 | 14 |
34 define float @test_floor(float %C) { | 15 declare double @llvm.floor.f64(double) |
16 declare double @llvm.ceil.f64(double) | |
17 declare double @llvm.round.f64(double) | |
18 declare double @llvm.nearbyint.f64(double) | |
19 declare double @llvm.trunc.f64(double) | |
20 declare double @llvm.fabs.f64(double) | |
21 | |
22 ; ALL-LABEL: @test_shrink_libcall_floor( | |
23 ; DO-SIMPLIFY: call float @llvm.floor.f32( | |
24 ; C89-SIMPLIFY: call float @llvm.floor.f32( | |
25 ; DONT-SIMPLIFY: call float @llvm.floor.f32( | |
26 define float @test_shrink_libcall_floor(float %C) { | |
35 %D = fpext float %C to double | 27 %D = fpext float %C to double |
36 ; --> floorf | 28 ; --> floorf |
37 %E = call double @floor(double %D) | 29 %E = call double @floor(double %D) |
38 %F = fptrunc double %E to float | 30 %F = fptrunc double %E to float |
39 ret float %F | 31 ret float %F |
40 } | 32 } |
41 | 33 |
42 define float @test_ceil(float %C) { | 34 ; ALL-LABEL: @test_shrink_libcall_ceil( |
35 ; DO-SIMPLIFY: call float @llvm.ceil.f32( | |
36 ; C89-SIMPLIFY: call float @llvm.ceil.f32( | |
37 ; DONT-SIMPLIFY: call float @llvm.ceil.f32( | |
38 define float @test_shrink_libcall_ceil(float %C) { | |
43 %D = fpext float %C to double | 39 %D = fpext float %C to double |
44 ; --> ceilf | 40 ; --> ceilf |
45 %E = call double @ceil(double %D) | 41 %E = call double @ceil(double %D) |
46 %F = fptrunc double %E to float | 42 %F = fptrunc double %E to float |
47 ret float %F | 43 ret float %F |
48 } | 44 } |
49 | 45 |
50 define float @test_round(float %C) { | 46 ; ALL-LABEL: @test_shrink_libcall_round( |
47 ; DO-SIMPLIFY: call float @llvm.round.f32( | |
48 ; C89-SIMPLIFY: call double @round( | |
49 ; DONT-SIMPLIFY: call double @round( | |
50 define float @test_shrink_libcall_round(float %C) { | |
51 %D = fpext float %C to double | 51 %D = fpext float %C to double |
52 ; --> roundf | 52 ; --> roundf |
53 %E = call double @round(double %D) | 53 %E = call double @round(double %D) |
54 %F = fptrunc double %E to float | 54 %F = fptrunc double %E to float |
55 ret float %F | 55 ret float %F |
56 } | 56 } |
57 | 57 |
58 define float @test_nearbyint(float %C) { | 58 ; ALL-LABEL: @test_shrink_libcall_nearbyint( |
59 ; DO-SIMPLIFY: call float @llvm.nearbyint.f32( | |
60 ; C89-SIMPLIFY: call double @nearbyint( | |
61 ; DONT-SIMPLIFY: call double @nearbyint( | |
62 define float @test_shrink_libcall_nearbyint(float %C) { | |
59 %D = fpext float %C to double | 63 %D = fpext float %C to double |
60 ; --> nearbyintf | 64 ; --> nearbyintf |
61 %E = call double @nearbyint(double %D) | 65 %E = call double @nearbyint(double %D) |
62 %F = fptrunc double %E to float | 66 %F = fptrunc double %E to float |
63 ret float %F | 67 ret float %F |
64 } | 68 } |
65 | 69 |
66 define float @test_trunc(float %C) { | 70 ; ALL-LABEL: @test_shrink_libcall_trunc( |
71 ; DO-SIMPLIFY: call float @llvm.trunc.f32( | |
72 ; DONT-SIMPLIFY: call double @trunc( | |
73 define float @test_shrink_libcall_trunc(float %C) { | |
67 %D = fpext float %C to double | 74 %D = fpext float %C to double |
68 ; --> truncf | 75 ; --> truncf |
69 %E = call double @trunc(double %D) | 76 %E = call double @trunc(double %D) |
70 %F = fptrunc double %E to float | 77 %F = fptrunc double %E to float |
71 ret float %F | 78 ret float %F |
72 } | 79 } |
73 | 80 |
74 define float @test_fabs(float %C) { | 81 ; ALL-LABEL: @test_shrink_libcall_fabs( |
82 ; DO-SIMPLIFY: call float @llvm.fabs.f32( | |
83 | |
84 ; This is replaced with the intrinsic, which does the right thing on | |
85 ; all platforms. | |
86 ; DONT-SIMPLIFY: call float @llvm.fabs.f32( | |
87 define float @test_shrink_libcall_fabs(float %C) { | |
75 %D = fpext float %C to double | 88 %D = fpext float %C to double |
76 ; --> fabsf | 89 ; --> fabsf |
77 %E = call double @fabs(double %D) | 90 %E = call double @fabs(double %D) |
78 %F = fptrunc double %E to float | 91 %F = fptrunc double %E to float |
79 ret float %F | 92 ret float %F |
80 } | 93 } |
94 | |
95 ; Make sure fast math flags are preserved | |
96 ; ALL-LABEL: @test_shrink_libcall_fabs_fast( | |
97 ; DO-SIMPLIFY: call fast float @llvm.fabs.f32( | |
98 define float @test_shrink_libcall_fabs_fast(float %C) { | |
99 %D = fpext float %C to double | |
100 ; --> fabsf | |
101 %E = call fast double @fabs(double %D) | |
102 %F = fptrunc double %E to float | |
103 ret float %F | |
104 } | |
105 | |
106 ; ALL-LABEL: @test_shrink_intrin_floor( | |
107 ; ALL: call float @llvm.floor.f32( | |
108 define float @test_shrink_intrin_floor(float %C) { | |
109 %D = fpext float %C to double | |
110 ; --> floorf | |
111 %E = call double @llvm.floor.f64(double %D) | |
112 %F = fptrunc double %E to float | |
113 ret float %F | |
114 } | |
115 | |
116 ; ALL-LABEL: @test_shrink_intrin_ceil( | |
117 ; ALL: call float @llvm.ceil.f32( | |
118 define float @test_shrink_intrin_ceil(float %C) { | |
119 %D = fpext float %C to double | |
120 ; --> ceilf | |
121 %E = call double @llvm.ceil.f64(double %D) | |
122 %F = fptrunc double %E to float | |
123 ret float %F | |
124 } | |
125 | |
126 ; ALL-LABEL: @test_shrink_intrin_round( | |
127 ; ALL: call float @llvm.round.f32( | |
128 define float @test_shrink_intrin_round(float %C) { | |
129 %D = fpext float %C to double | |
130 ; --> roundf | |
131 %E = call double @llvm.round.f64(double %D) | |
132 %F = fptrunc double %E to float | |
133 ret float %F | |
134 } | |
135 | |
136 ; ALL-LABEL: @test_shrink_intrin_nearbyint( | |
137 ; ALL: call float @llvm.nearbyint.f32( | |
138 define float @test_shrink_intrin_nearbyint(float %C) { | |
139 %D = fpext float %C to double | |
140 ; --> nearbyintf | |
141 %E = call double @llvm.nearbyint.f64(double %D) | |
142 %F = fptrunc double %E to float | |
143 ret float %F | |
144 } | |
145 | |
146 ; ALL-LABEL: @test_shrink_intrin_trunc( | |
147 ; ALL-SIMPLIFY: call float @llvm.trunc.f32( | |
148 define float @test_shrink_intrin_trunc(float %C) { | |
149 %D = fpext float %C to double | |
150 %E = call double @llvm.trunc.f64(double %D) | |
151 %F = fptrunc double %E to float | |
152 ret float %F | |
153 } | |
154 | |
155 ; ALL-LABEL: @test_shrink_intrin_fabs( | |
156 ; ALL: call float @llvm.fabs.f32( | |
157 define float @test_shrink_intrin_fabs(float %C) { | |
158 %D = fpext float %C to double | |
159 %E = call double @llvm.fabs.f64(double %D) | |
160 %F = fptrunc double %E to float | |
161 ret float %F | |
162 } | |
163 | |
164 ; Make sure fast math flags are preserved | |
165 ; ALL-LABEL: @test_shrink_intrin_fabs_fast( | |
166 ; ALL: call fast float @llvm.fabs.f32( | |
167 define float @test_shrink_intrin_fabs_fast(float %C) { | |
168 %D = fpext float %C to double | |
169 %E = call fast double @llvm.fabs.f64(double %D) | |
170 %F = fptrunc double %E to float | |
171 ret float %F | |
172 } | |
173 | |
174 ; ALL-LABEL: @test_no_shrink_intrin_floor( | |
175 ; ALL: call double @llvm.floor.f64( | |
176 define float @test_no_shrink_intrin_floor(double %D) { | |
177 %E = call double @llvm.floor.f64(double %D) | |
178 %F = fptrunc double %E to float | |
179 ret float %F | |
180 } | |
181 | |
182 ; ALL-LABEL: @test_no_shrink_intrin_ceil( | |
183 ; ALL: call double @llvm.ceil.f64( | |
184 define float @test_no_shrink_intrin_ceil(double %D) { | |
185 %E = call double @llvm.ceil.f64(double %D) | |
186 %F = fptrunc double %E to float | |
187 ret float %F | |
188 } | |
189 | |
190 ; ALL-LABEL: @test_no_shrink_intrin_round( | |
191 ; ALL: call double @llvm.round.f64( | |
192 define float @test_no_shrink_intrin_round(double %D) { | |
193 %E = call double @llvm.round.f64(double %D) | |
194 %F = fptrunc double %E to float | |
195 ret float %F | |
196 } | |
197 | |
198 ; ALL-LABEL: @test_no_shrink_intrin_nearbyint( | |
199 ; ALL: call double @llvm.nearbyint.f64( | |
200 define float @test_no_shrink_intrin_nearbyint(double %D) { | |
201 %E = call double @llvm.nearbyint.f64(double %D) | |
202 %F = fptrunc double %E to float | |
203 ret float %F | |
204 } | |
205 | |
206 ; ALL-LABEL: @test_no_shrink_intrin_trunc( | |
207 ; ALL-SIMPLIFY: call double @llvm.trunc.f64( | |
208 define float @test_no_shrink_intrin_trunc(double %D) { | |
209 %E = call double @llvm.trunc.f64(double %D) | |
210 %F = fptrunc double %E to float | |
211 ret float %F | |
212 } | |
213 | |
214 ; ALL-LABEL: @test_shrink_intrin_fabs_double_src( | |
215 ; ALL: call float @llvm.fabs.f32( | |
216 define float @test_shrink_intrin_fabs_double_src(double %D) { | |
217 %E = call double @llvm.fabs.f64(double %D) | |
218 %F = fptrunc double %E to float | |
219 ret float %F | |
220 } | |
221 | |
222 ; Make sure fast math flags are preserved | |
223 ; ALL-LABEL: @test_shrink_intrin_fabs_fast_double_src( | |
224 ; ALL: call fast float @llvm.fabs.f32( | |
225 define float @test_shrink_intrin_fabs_fast_double_src(double %D) { | |
226 %E = call fast double @llvm.fabs.f64(double %D) | |
227 %F = fptrunc double %E to float | |
228 ret float %F | |
229 } | |
230 | |
231 ; ALL-LABEL: @test_shrink_float_convertible_constant_intrin_floor( | |
232 ; ALL: ret float 2.000000e+00 | |
233 define float @test_shrink_float_convertible_constant_intrin_floor() { | |
234 %E = call double @llvm.floor.f64(double 2.1) | |
235 %F = fptrunc double %E to float | |
236 ret float %F | |
237 } | |
238 | |
239 ; ALL-LABEL: @test_shrink_float_convertible_constant_intrin_ceil( | |
240 ; ALL: ret float 3.000000e+00 | |
241 define float @test_shrink_float_convertible_constant_intrin_ceil() { | |
242 %E = call double @llvm.ceil.f64(double 2.1) | |
243 %F = fptrunc double %E to float | |
244 ret float %F | |
245 } | |
246 | |
247 ; ALL-LABEL: @test_shrink_float_convertible_constant_intrin_round( | |
248 ; ALL: ret float 2.000000e+00 | |
249 define float @test_shrink_float_convertible_constant_intrin_round() { | |
250 %E = call double @llvm.round.f64(double 2.1) | |
251 %F = fptrunc double %E to float | |
252 ret float %F | |
253 } | |
254 | |
255 ; ALL-LABEL: @test_shrink_float_convertible_constant_intrin_nearbyint( | |
256 ; ALL: ret float 2.000000e+00 | |
257 define float @test_shrink_float_convertible_constant_intrin_nearbyint() { | |
258 %E = call double @llvm.nearbyint.f64(double 2.1) | |
259 %F = fptrunc double %E to float | |
260 ret float %F | |
261 } | |
262 | |
263 ; ALL-LABEL: @test_shrink_float_convertible_constant_intrin_trunc( | |
264 ; ALL: ret float 2.000000e+00 | |
265 define float @test_shrink_float_convertible_constant_intrin_trunc() { | |
266 %E = call double @llvm.trunc.f64(double 2.1) | |
267 %F = fptrunc double %E to float | |
268 ret float %F | |
269 } | |
270 | |
271 ; ALL-LABEL: @test_shrink_float_convertible_constant_intrin_fabs( | |
272 ; ALL: ret float 0x4000CCCCC0000000 | |
273 define float @test_shrink_float_convertible_constant_intrin_fabs() { | |
274 %E = call double @llvm.fabs.f64(double 2.1) | |
275 %F = fptrunc double %E to float | |
276 ret float %F | |
277 } | |
278 | |
279 ; Make sure fast math flags are preserved | |
280 ; ALL-LABEL: @test_shrink_float_convertible_constant_intrin_fabs_fast( | |
281 ; ALL: ret float 0x4000CCCCC0000000 | |
282 define float @test_shrink_float_convertible_constant_intrin_fabs_fast() { | |
283 %E = call fast double @llvm.fabs.f64(double 2.1) | |
284 %F = fptrunc double %E to float | |
285 ret float %F | |
286 } | |
287 | |
288 ; ALL-LABEL: @test_no_shrink_mismatched_type_intrin_floor( | |
289 ; ALL-NEXT: %E = call double @llvm.floor.f64(double %D) | |
290 ; ALL-NEXT: %F = fptrunc double %E to half | |
291 ; ALL-NEXT: ret half %F | |
292 define half @test_no_shrink_mismatched_type_intrin_floor(double %D) { | |
293 %E = call double @llvm.floor.f64(double %D) | |
294 %F = fptrunc double %E to half | |
295 ret half %F | |
296 } | |
297 | |
298 ; ALL-LABEL: @test_no_shrink_mismatched_type_intrin_ceil( | |
299 ; ALL-NEXT: %E = call double @llvm.ceil.f64(double %D) | |
300 ; ALL-NEXT: %F = fptrunc double %E to half | |
301 ; ALL-NEXT: ret half %F | |
302 define half @test_no_shrink_mismatched_type_intrin_ceil(double %D) { | |
303 %E = call double @llvm.ceil.f64(double %D) | |
304 %F = fptrunc double %E to half | |
305 ret half %F | |
306 } | |
307 | |
308 ; ALL-LABEL: @test_no_shrink_mismatched_type_intrin_round( | |
309 ; ALL-NEXT: %E = call double @llvm.round.f64(double %D) | |
310 ; ALL-NEXT: %F = fptrunc double %E to half | |
311 ; ALL-NEXT: ret half %F | |
312 define half @test_no_shrink_mismatched_type_intrin_round(double %D) { | |
313 %E = call double @llvm.round.f64(double %D) | |
314 %F = fptrunc double %E to half | |
315 ret half %F | |
316 } | |
317 | |
318 ; ALL-LABEL: @test_no_shrink_mismatched_type_intrin_nearbyint( | |
319 ; ALL-NEXT: %E = call double @llvm.nearbyint.f64(double %D) | |
320 ; ALL-NEXT: %F = fptrunc double %E to half | |
321 ; ALL-NEXT: ret half %F | |
322 define half @test_no_shrink_mismatched_type_intrin_nearbyint(double %D) { | |
323 %E = call double @llvm.nearbyint.f64(double %D) | |
324 %F = fptrunc double %E to half | |
325 ret half %F | |
326 } | |
327 | |
328 ; ALL-LABEL: @test_no_shrink_mismatched_type_intrin_trunc( | |
329 ; ALL-NEXT: %E = call double @llvm.trunc.f64(double %D) | |
330 ; ALL-NEXT: %F = fptrunc double %E to half | |
331 ; ALL-NEXT: ret half %F | |
332 define half @test_no_shrink_mismatched_type_intrin_trunc(double %D) { | |
333 %E = call double @llvm.trunc.f64(double %D) | |
334 %F = fptrunc double %E to half | |
335 ret half %F | |
336 } | |
337 | |
338 ; ALL-LABEL: @test_shrink_mismatched_type_intrin_fabs_double_src( | |
339 ; ALL-NEXT: %1 = fptrunc double %D to half | |
340 ; ALL-NEXT: %F = call half @llvm.fabs.f16(half %1) | |
341 ; ALL-NEXT: ret half %F | |
342 define half @test_shrink_mismatched_type_intrin_fabs_double_src(double %D) { | |
343 %E = call double @llvm.fabs.f64(double %D) | |
344 %F = fptrunc double %E to half | |
345 ret half %F | |
346 } | |
347 | |
348 ; Make sure fast math flags are preserved | |
349 ; ALL-LABEL: @test_mismatched_type_intrin_fabs_fast_double_src( | |
350 ; ALL-NEXT: %1 = fptrunc double %D to half | |
351 ; ALL-NEXT: %F = call fast half @llvm.fabs.f16(half %1) | |
352 ; ALL-NEXT: ret half %F | |
353 define half @test_mismatched_type_intrin_fabs_fast_double_src(double %D) { | |
354 %E = call fast double @llvm.fabs.f64(double %D) | |
355 %F = fptrunc double %E to half | |
356 ret half %F | |
357 } | |
358 | |
359 ; ALL-LABEL: @test_shrink_intrin_floor_fp16_src( | |
360 ; ALL-NEXT: %E = call half @llvm.floor.f16(half %C) | |
361 ; ALL-NEXT: %1 = fpext half %E to double | |
362 ; ALL-NEXT: %F = fptrunc double %1 to float | |
363 define float @test_shrink_intrin_floor_fp16_src(half %C) { | |
364 %D = fpext half %C to double | |
365 %E = call double @llvm.floor.f64(double %D) | |
366 %F = fptrunc double %E to float | |
367 ret float %F | |
368 } | |
369 | |
370 ; ALL-LABEL: @test_shrink_intrin_ceil_fp16_src( | |
371 ; ALL-NEXT: %E = call half @llvm.ceil.f16(half %C) | |
372 ; ALL-NEXT: %1 = fpext half %E to double | |
373 ; ALL-NEXT: %F = fptrunc double %1 to float | |
374 ; ALL-NEXT: ret float %F | |
375 define float @test_shrink_intrin_ceil_fp16_src(half %C) { | |
376 %D = fpext half %C to double | |
377 %E = call double @llvm.ceil.f64(double %D) | |
378 %F = fptrunc double %E to float | |
379 ret float %F | |
380 } | |
381 | |
382 ; ALL-LABEL: @test_shrink_intrin_round_fp16_src( | |
383 ; ALL-NEXT: %E = call half @llvm.round.f16(half %C) | |
384 ; ALL-NEXT: %1 = fpext half %E to double | |
385 ; ALL-NEXT: %F = fptrunc double %1 to float | |
386 ; ALL-NEXT: ret float %F | |
387 define float @test_shrink_intrin_round_fp16_src(half %C) { | |
388 %D = fpext half %C to double | |
389 %E = call double @llvm.round.f64(double %D) | |
390 %F = fptrunc double %E to float | |
391 ret float %F | |
392 } | |
393 | |
394 ; ALL-LABEL: @test_shrink_intrin_nearbyint_fp16_src( | |
395 ; ALL-NEXT: %E = call half @llvm.nearbyint.f16(half %C) | |
396 ; ALL-NEXT: %1 = fpext half %E to double | |
397 ; ALL-NEXT: %F = fptrunc double %1 to float | |
398 ; ALL-NEXT: ret float %F | |
399 define float @test_shrink_intrin_nearbyint_fp16_src(half %C) { | |
400 %D = fpext half %C to double | |
401 %E = call double @llvm.nearbyint.f64(double %D) | |
402 %F = fptrunc double %E to float | |
403 ret float %F | |
404 } | |
405 | |
406 ; ALL-LABEL: @test_shrink_intrin_trunc_fp16_src( | |
407 ; ALL-NEXT: %E = call half @llvm.trunc.f16(half %C) | |
408 ; ALL-NEXT: %1 = fpext half %E to double | |
409 ; ALL-NEXT: %F = fptrunc double %1 to float | |
410 ; ALL-NEXT: ret float %F | |
411 define float @test_shrink_intrin_trunc_fp16_src(half %C) { | |
412 %D = fpext half %C to double | |
413 %E = call double @llvm.trunc.f64(double %D) | |
414 %F = fptrunc double %E to float | |
415 ret float %F | |
416 } | |
417 | |
418 ; ALL-LABEL: @test_shrink_intrin_fabs_fp16_src( | |
419 ; ALL-NEXT: %E = call half @llvm.fabs.f16(half %C) | |
420 ; ALL-NEXT: %1 = fpext half %E to double | |
421 ; ALL-NEXT: %F = fptrunc double %1 to float | |
422 ; ALL-NEXT: ret float %F | |
423 define float @test_shrink_intrin_fabs_fp16_src(half %C) { | |
424 %D = fpext half %C to double | |
425 %E = call double @llvm.fabs.f64(double %D) | |
426 %F = fptrunc double %E to float | |
427 ret float %F | |
428 } | |
429 | |
430 ; Make sure fast math flags are preserved | |
431 ; ALL-LABEL: @test_shrink_intrin_fabs_fast_fp16_src( | |
432 ; ALL-NEXT: %E = call fast half @llvm.fabs.f16(half %C) | |
433 ; ALL-NEXT: %1 = fpext half %E to double | |
434 ; ALL-NEXT: %F = fptrunc double %1 to float | |
435 ; ALL-NEXT: ret float %F | |
436 define float @test_shrink_intrin_fabs_fast_fp16_src(half %C) { | |
437 %D = fpext half %C to double | |
438 %E = call fast double @llvm.fabs.f64(double %D) | |
439 %F = fptrunc double %E to float | |
440 ret float %F | |
441 } | |
442 | |
443 ; ALL-LABEL: @test_no_shrink_intrin_floor_multi_use_fpext( | |
444 ; ALL: %D = fpext half %C to double | |
445 ; ALL: call double @llvm.floor.f64 | |
446 define float @test_no_shrink_intrin_floor_multi_use_fpext(half %C) { | |
447 %D = fpext half %C to double | |
448 store volatile double %D, double* undef | |
449 %E = call double @llvm.floor.f64(double %D) | |
450 %F = fptrunc double %E to float | |
451 ret float %F | |
452 } | |
453 | |
454 ; ALL-LABEL: @test_no_shrink_intrin_fabs_multi_use_fpext( | |
455 ; ALL: %D = fpext half %C to double | |
456 ; ALL: call double @llvm.fabs.f64 | |
457 define float @test_no_shrink_intrin_fabs_multi_use_fpext(half %C) { | |
458 %D = fpext half %C to double | |
459 store volatile double %D, double* undef | |
460 %E = call double @llvm.fabs.f64(double %D) | |
461 %F = fptrunc double %E to float | |
462 ret float %F | |
463 } |