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 6 define float @fold_from_fp16_to_fp32() { 7 ; CHECK-LABEL: @fold_from_fp16_to_fp32 8 ; CHECK: ret float 0.000000e+00 9 entry: 10 %0 = call float @llvm.convert.from.fp16.f32(i16 0) 11 ret float %0 12 } 13 14 define double @fold_from_fp16_to_fp64() { 15 ; CHECK-LABEL: @fold_from_fp16_to_fp64 16 ; CHECK: ret double 0.000000e+00 17 entry: 18 %0 = call double @llvm.convert.from.fp16.f64(i16 0) 19 ret double %0 20 } 21 22 define x86_fp80 @fold_from_fp16_to_fp80() { 23 ; CHECK-LABEL: @fold_from_fp16_to_fp80 24 ; CHECK: ret x86_fp80 0xK00000000000000000000 25 entry: 26 %0 = call x86_fp80 @llvm.convert.from.fp16.f80(i16 0) 27 ret x86_fp80 %0 28 } 29 30 define fp128 @fold_from_fp16_to_fp128() { 31 ; CHECK-LABEL: @fold_from_fp16_to_fp128 32 ; CHECK: ret fp128 0xL00000000000000000000000000000000 33 entry: 34 %0 = call fp128 @llvm.convert.from.fp16.f128(i16 0) 35 ret fp128 %0 36 } 37 38 define ppc_fp128 @fold_from_fp16_to_ppcfp128() { 39 ; CHECK-LABEL: @fold_from_fp16_to_ppcfp128 40 ; CHECK: ret ppc_fp128 0xM00000000000000000000000000000000 41 entry: 42 %0 = call ppc_fp128 @llvm.convert.from.fp16.ppcf128(i16 0) 43 ret ppc_fp128 %0 44 } 45 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 49 entry: 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 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 58 entry: 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 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 67 entry: 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 73 define fp128 @fold_from_fp16_to_fp128_b() { 74 ; CHECK-LABEL: @fold_from_fp16_to_fp128_b 75 ; CHECK: ret fp128 0xL00000000000000004001000000000000 76 entry: 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 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 85 entry: 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 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) 98