1 ; RUN: opt -constprop -S < %s | FileCheck %s
3 ; Verify that we don't crash with an assertion failure when constant folding
4 ; a call to intrinsic 'convert.from.fp16' if the return type is not 'float'.
6 define float @fold_from_fp16_to_fp32() {
7 ; CHECK-LABEL: @fold_from_fp16_to_fp32
8 ; CHECK: ret float 0.000000e+00
10 %0 = call float @llvm.convert.from.fp16.f32(i16 0)
14 define double @fold_from_fp16_to_fp64() {
15 ; CHECK-LABEL: @fold_from_fp16_to_fp64
16 ; CHECK: ret double 0.000000e+00
18 %0 = call double @llvm.convert.from.fp16.f64(i16 0)
22 define x86_fp80 @fold_from_fp16_to_fp80() {
23 ; CHECK-LABEL: @fold_from_fp16_to_fp80
24 ; CHECK: ret x86_fp80 0xK00000000000000000000
26 %0 = call x86_fp80 @llvm.convert.from.fp16.f80(i16 0)
30 define fp128 @fold_from_fp16_to_fp128() {
31 ; CHECK-LABEL: @fold_from_fp16_to_fp128
32 ; CHECK: ret fp128 0xL00000000000000000000000000000000
34 %0 = call fp128 @llvm.convert.from.fp16.f128(i16 0)
38 define ppc_fp128 @fold_from_fp16_to_ppcfp128() {
39 ; CHECK-LABEL: @fold_from_fp16_to_ppcfp128
40 ; CHECK: ret ppc_fp128 0xM00000000000000000000000000000000
42 %0 = call ppc_fp128 @llvm.convert.from.fp16.ppcf128(i16 0)
46 define float @fold_from_fp16_to_fp32_b() {
47 ; CHECK-LABEL: @fold_from_fp16_to_fp32_b
48 ; CHECK: ret float 4.000000e+00
50 %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0)
51 %1 = call float @llvm.convert.from.fp16.f32(i16 %0)
55 define double @fold_from_fp16_to_fp64_b() {
56 ; CHECK-LABEL: @fold_from_fp16_to_fp64_b
57 ; CHECK: ret double 4.000000e+00
59 %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0)
60 %1 = call double @llvm.convert.from.fp16.f64(i16 %0)
64 define x86_fp80 @fold_from_fp16_to_fp80_b() {
65 ; CHECK-LABEL: @fold_from_fp16_to_fp80_b
66 ; CHECK: ret x86_fp80 0xK40018000000000000000
68 %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0)
69 %1 = call x86_fp80 @llvm.convert.from.fp16.f80(i16 %0)
73 define fp128 @fold_from_fp16_to_fp128_b() {
74 ; CHECK-LABEL: @fold_from_fp16_to_fp128_b
75 ; CHECK: ret fp128 0xL00000000000000004001000000000000
77 %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0)
78 %1 = call fp128 @llvm.convert.from.fp16.f128(i16 %0)
82 define ppc_fp128 @fold_from_fp16_to_ppcfp128_b() {
83 ; CHECK-LABEL: @fold_from_fp16_to_ppcfp128_b
84 ; CHECK: ret ppc_fp128 0xM40100000000000000000000000000000
86 %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0)
87 %1 = call ppc_fp128 @llvm.convert.from.fp16.ppcf128(i16 %0)
92 declare i16 @llvm.convert.to.fp16.f64(double)
93 declare float @llvm.convert.from.fp16.f32(i16)
94 declare double @llvm.convert.from.fp16.f64(i16)
95 declare x86_fp80 @llvm.convert.from.fp16.f80(i16)
96 declare fp128 @llvm.convert.from.fp16.f128(i16)
97 declare ppc_fp128 @llvm.convert.from.fp16.ppcf128(i16)