1; RUN: opt -constprop -S < %s | FileCheck %s 2 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'. 5 6define float @fold_from_fp16_to_fp32() { 7; CHECK-LABEL: @fold_from_fp16_to_fp32 8; CHECK: ret float 0.000000e+00 9entry: 10 %0 = call float @llvm.convert.from.fp16.f32(i16 0) 11 ret float %0 12} 13 14define double @fold_from_fp16_to_fp64() { 15; CHECK-LABEL: @fold_from_fp16_to_fp64 16; CHECK: ret double 0.000000e+00 17entry: 18 %0 = call double @llvm.convert.from.fp16.f64(i16 0) 19 ret double %0 20} 21 22define x86_fp80 @fold_from_fp16_to_fp80() { 23; CHECK-LABEL: @fold_from_fp16_to_fp80 24; CHECK: ret x86_fp80 0xK00000000000000000000 25entry: 26 %0 = call x86_fp80 @llvm.convert.from.fp16.f80(i16 0) 27 ret x86_fp80 %0 28} 29 30define fp128 @fold_from_fp16_to_fp128() { 31; CHECK-LABEL: @fold_from_fp16_to_fp128 32; CHECK: ret fp128 0xL00000000000000000000000000000000 33entry: 34 %0 = call fp128 @llvm.convert.from.fp16.f128(i16 0) 35 ret fp128 %0 36} 37 38define ppc_fp128 @fold_from_fp16_to_ppcfp128() { 39; CHECK-LABEL: @fold_from_fp16_to_ppcfp128 40; CHECK: ret ppc_fp128 0xM00000000000000000000000000000000 41entry: 42 %0 = call ppc_fp128 @llvm.convert.from.fp16.ppcf128(i16 0) 43 ret ppc_fp128 %0 44} 45 46define float @fold_from_fp16_to_fp32_b() { 47; CHECK-LABEL: @fold_from_fp16_to_fp32_b 48; CHECK: ret float 4.000000e+00 49entry: 50 %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0) 51 %1 = call float @llvm.convert.from.fp16.f32(i16 %0) 52 ret float %1 53} 54 55define double @fold_from_fp16_to_fp64_b() { 56; CHECK-LABEL: @fold_from_fp16_to_fp64_b 57; CHECK: ret double 4.000000e+00 58entry: 59 %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0) 60 %1 = call double @llvm.convert.from.fp16.f64(i16 %0) 61 ret double %1 62} 63 64define x86_fp80 @fold_from_fp16_to_fp80_b() { 65; CHECK-LABEL: @fold_from_fp16_to_fp80_b 66; CHECK: ret x86_fp80 0xK40018000000000000000 67entry: 68 %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0) 69 %1 = call x86_fp80 @llvm.convert.from.fp16.f80(i16 %0) 70 ret x86_fp80 %1 71} 72 73define fp128 @fold_from_fp16_to_fp128_b() { 74; CHECK-LABEL: @fold_from_fp16_to_fp128_b 75; CHECK: ret fp128 0xL00000000000000004001000000000000 76entry: 77 %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0) 78 %1 = call fp128 @llvm.convert.from.fp16.f128(i16 %0) 79 ret fp128 %1 80} 81 82define ppc_fp128 @fold_from_fp16_to_ppcfp128_b() { 83; CHECK-LABEL: @fold_from_fp16_to_ppcfp128_b 84; CHECK: ret ppc_fp128 0xM40100000000000000000000000000000 85entry: 86 %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0) 87 %1 = call ppc_fp128 @llvm.convert.from.fp16.ppcf128(i16 %0) 88 ret ppc_fp128 %1 89} 90 91 92declare i16 @llvm.convert.to.fp16.f64(double) 93declare float @llvm.convert.from.fp16.f32(i16) 94declare double @llvm.convert.from.fp16.f64(i16) 95declare x86_fp80 @llvm.convert.from.fp16.f80(i16) 96declare fp128 @llvm.convert.from.fp16.f128(i16) 97declare ppc_fp128 @llvm.convert.from.fp16.ppcf128(i16) 98