Merging r261039:
[oota-llvm.git] / test / CodeGen / X86 / fastmath-float-half-conversion.ll
1 ; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=+f16c < %s | FileCheck %s --check-prefix=ALL --check-prefix=F16C
2 ; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=+avx < %s | FileCheck %s --check-prefix=ALL --check-prefix=AVX
3
4 define zeroext i16 @test1_fast(double %d) #0 {
5 ; ALL-LABEL: test1_fast:
6 ; F16C-NOT: callq {{_+}}truncdfhf2
7 ; F16C: vcvtsd2ss %xmm0, %xmm0, %xmm0
8 ; F16C-NEXT: vcvtps2ph $0, %xmm0, %xmm0
9 ; AVX: callq {{_+}}truncdfhf2
10 ; ALL: ret
11 entry:
12   %0 = tail call i16 @llvm.convert.to.fp16.f64(double %d)
13   ret i16 %0
14 }
15
16 define zeroext i16 @test2_fast(x86_fp80 %d) #0 {
17 ; ALL-LABEL: test2_fast:
18 ; F16C-NOT: callq {{_+}}truncxfhf2
19 ; F16C: fldt
20 ; F16C-NEXT: fstps
21 ; F16C-NEXT: vmovss
22 ; F16C-NEXT: vcvtps2ph $0, %xmm0, %xmm0
23 ; AVX: callq {{_+}}truncxfhf2
24 ; ALL: ret
25 entry:
26   %0 = tail call i16 @llvm.convert.to.fp16.f80(x86_fp80 %d)
27   ret i16 %0
28 }
29
30 define zeroext i16 @test1(double %d) #1 {
31 ; ALL-LABEL: test1:
32 ; ALL: callq  {{_+}}truncdfhf2
33 ; ALL: ret
34 entry:
35   %0 = tail call i16 @llvm.convert.to.fp16.f64(double %d)
36   ret i16 %0
37 }
38
39 define zeroext i16 @test2(x86_fp80 %d) #1 {
40 ; ALL-LABEL: test2:
41 ; ALL: callq  {{_+}}truncxfhf2
42 ; ALL: ret
43 entry:
44   %0 = tail call i16 @llvm.convert.to.fp16.f80(x86_fp80 %d)
45   ret i16 %0
46 }
47
48 declare i16 @llvm.convert.to.fp16.f64(double)
49 declare i16 @llvm.convert.to.fp16.f80(x86_fp80)
50
51 attributes #0 = { nounwind readnone uwtable "unsafe-fp-math"="true" "use-soft-float"="false" }
52 attributes #1 = { nounwind readnone uwtable "unsafe-fp-math"="false" "use-soft-float"="false" }