• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
4define 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 $4, %xmm0, %xmm0
9; AVX: callq {{_+}}truncdfhf2
10; ALL: ret
11entry:
12  %0 = tail call i16 @llvm.convert.to.fp16.f64(double %d)
13  ret i16 %0
14}
15
16define 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 $4, %xmm0, %xmm0
23; AVX: callq {{_+}}truncxfhf2
24; ALL: ret
25entry:
26  %0 = tail call i16 @llvm.convert.to.fp16.f80(x86_fp80 %d)
27  ret i16 %0
28}
29
30define zeroext i16 @test1(double %d) #1 {
31; ALL-LABEL: test1:
32; ALL: callq  {{_+}}truncdfhf2
33; ALL: ret
34entry:
35  %0 = tail call i16 @llvm.convert.to.fp16.f64(double %d)
36  ret i16 %0
37}
38
39define zeroext i16 @test2(x86_fp80 %d) #1 {
40; ALL-LABEL: test2:
41; ALL: callq  {{_+}}truncxfhf2
42; ALL: ret
43entry:
44  %0 = tail call i16 @llvm.convert.to.fp16.f80(x86_fp80 %d)
45  ret i16 %0
46}
47
48declare i16 @llvm.convert.to.fp16.f64(double)
49declare i16 @llvm.convert.to.fp16.f80(x86_fp80)
50
51attributes #0 = { nounwind readnone uwtable "unsafe-fp-math"="true" "use-soft-float"="false" }
52attributes #1 = { nounwind readnone uwtable "unsafe-fp-math"="false" "use-soft-float"="false" }
53