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