1 ; RUN: llc -march=hexagon < %s | FileCheck %s
3 ; This test validates the following facts for half-precision floating point
5 ; Generate correct libcall names for conversion from fp16 to fp32.
7 ; The extension from fp16 to fp64 is implicitly handled by __extendhfsf2 and convert_sf2d.
9 ; Generate correcct libcall names for conversion from fp32/fp64 to fp16
10 ; (__truncsfhf2 and __truncdfhf2)
11 ; Verify that we generate loads and stores of halfword.
13 ; Validate that we generate correct lib calls to convert fp16
16 ;CHECK: call __extendhfsf2
18 define dso_local float @test1(ptr nocapture readonly %a) local_unnamed_addr #0 {
20 %0 = load i16, ptr %a, align 2
21 %1 = tail call float @llvm.convert.from.fp16.f32(i16 %0)
26 ;CHECK: call __extendhfsf2
29 define dso_local double @test2(ptr nocapture readonly %a) local_unnamed_addr #0 {
31 %0 = load i16, ptr %a, align 2
32 %1 = tail call double @llvm.convert.from.fp16.f64(i16 %0)
37 ;CHECK: call __truncsfhf2
38 ;CHECK: memh{{.*}}= r0
39 define dso_local void @test3(float %src, ptr nocapture %dst) local_unnamed_addr #0 {
41 %0 = tail call i16 @llvm.convert.to.fp16.f32(float %src)
42 store i16 %0, ptr %dst, align 2
47 ;CHECK: call __truncdfhf2
48 ;CHECK: memh{{.*}}= r0
49 define dso_local void @test4(double %src, ptr nocapture %dst) local_unnamed_addr #0 {
51 %0 = tail call i16 @llvm.convert.to.fp16.f64(double %src)
52 store i16 %0, ptr %dst, align 2
57 ;CHECK: call __extendhfsf2
58 ;CHECK: call __extendhfsf2
60 define dso_local float @test5(ptr nocapture readonly %a, ptr nocapture readonly %b) local_unnamed_addr #0 {
62 %0 = load i16, ptr %a, align 2
63 %1 = tail call float @llvm.convert.from.fp16.f32(i16 %0)
64 %2 = load i16, ptr %b, align 2
65 %3 = tail call float @llvm.convert.from.fp16.f32(i16 %2)
66 %add = fadd float %1, %3
70 declare float @llvm.convert.from.fp16.f32(i16) #1
71 declare double @llvm.convert.from.fp16.f64(i16) #1
72 declare i16 @llvm.convert.to.fp16.f32(float) #1
73 declare i16 @llvm.convert.to.fp16.f64(double) #1
75 attributes #0 = { nounwind readonly }
76 attributes #1 = { nounwind readnone }