llvm/clang/test/CodeGen/RISCV/__fp16-convert.c

// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
// RUN: %clang_cc1 -triple riscv64 -emit-llvm %s -o - \
// RUN:   | FileCheck %s

__fp16 y;
short z;
// CHECK-LABEL: @bar1(
// CHECK-NEXT:  entry:
// CHECK-NEXT:    [[TMP0:%.*]] = load half, ptr @y, align 2
// CHECK-NEXT:    [[CONV:%.*]] = fpext half [[TMP0]] to float
// CHECK-NEXT:    [[CONV1:%.*]] = fptosi float [[CONV]] to i16
// CHECK-NEXT:    store i16 [[CONV1]], ptr @z, align 2
// CHECK-NEXT:    ret void
//
void bar1(){
    z = y;
}
// CHECK-LABEL: @bar2(
// CHECK-NEXT:  entry:
// CHECK-NEXT:    [[TMP0:%.*]] = load i16, ptr @z, align 2
// CHECK-NEXT:    [[CONV:%.*]] = sitofp i16 [[TMP0]] to float
// CHECK-NEXT:    [[CONV1:%.*]] = fptrunc float [[CONV]] to half
// CHECK-NEXT:    store half [[CONV1]], ptr @y, align 2
// CHECK-NEXT:    ret void
//
void bar2(){
    y = z;
}