xref: /aosp_15_r20/external/llvm/test/Transforms/ConstProp/convert-from-fp16.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt -constprop -S < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; Verify that we don't crash with an assertion failure when constant folding
4*9880d681SAndroid Build Coastguard Worker; a call to intrinsic 'convert.from.fp16' if the return type is not 'float'.
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Workerdefine float @fold_from_fp16_to_fp32() {
7*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @fold_from_fp16_to_fp32
8*9880d681SAndroid Build Coastguard Worker; CHECK: ret float 0.000000e+00
9*9880d681SAndroid Build Coastguard Workerentry:
10*9880d681SAndroid Build Coastguard Worker  %0 = call float @llvm.convert.from.fp16.f32(i16 0)
11*9880d681SAndroid Build Coastguard Worker  ret float %0
12*9880d681SAndroid Build Coastguard Worker}
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Workerdefine double @fold_from_fp16_to_fp64() {
15*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @fold_from_fp16_to_fp64
16*9880d681SAndroid Build Coastguard Worker; CHECK: ret double 0.000000e+00
17*9880d681SAndroid Build Coastguard Workerentry:
18*9880d681SAndroid Build Coastguard Worker  %0 = call double @llvm.convert.from.fp16.f64(i16 0)
19*9880d681SAndroid Build Coastguard Worker  ret double %0
20*9880d681SAndroid Build Coastguard Worker}
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Workerdefine x86_fp80 @fold_from_fp16_to_fp80() {
23*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @fold_from_fp16_to_fp80
24*9880d681SAndroid Build Coastguard Worker; CHECK: ret x86_fp80 0xK00000000000000000000
25*9880d681SAndroid Build Coastguard Workerentry:
26*9880d681SAndroid Build Coastguard Worker  %0 = call x86_fp80 @llvm.convert.from.fp16.f80(i16 0)
27*9880d681SAndroid Build Coastguard Worker  ret x86_fp80 %0
28*9880d681SAndroid Build Coastguard Worker}
29*9880d681SAndroid Build Coastguard Worker
30*9880d681SAndroid Build Coastguard Workerdefine fp128 @fold_from_fp16_to_fp128() {
31*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @fold_from_fp16_to_fp128
32*9880d681SAndroid Build Coastguard Worker; CHECK: ret fp128 0xL00000000000000000000000000000000
33*9880d681SAndroid Build Coastguard Workerentry:
34*9880d681SAndroid Build Coastguard Worker  %0 = call fp128 @llvm.convert.from.fp16.f128(i16 0)
35*9880d681SAndroid Build Coastguard Worker  ret fp128 %0
36*9880d681SAndroid Build Coastguard Worker}
37*9880d681SAndroid Build Coastguard Worker
38*9880d681SAndroid Build Coastguard Workerdefine ppc_fp128 @fold_from_fp16_to_ppcfp128() {
39*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @fold_from_fp16_to_ppcfp128
40*9880d681SAndroid Build Coastguard Worker; CHECK: ret ppc_fp128 0xM00000000000000000000000000000000
41*9880d681SAndroid Build Coastguard Workerentry:
42*9880d681SAndroid Build Coastguard Worker  %0 = call ppc_fp128 @llvm.convert.from.fp16.ppcf128(i16 0)
43*9880d681SAndroid Build Coastguard Worker  ret ppc_fp128 %0
44*9880d681SAndroid Build Coastguard Worker}
45*9880d681SAndroid Build Coastguard Worker
46*9880d681SAndroid Build Coastguard Workerdefine float @fold_from_fp16_to_fp32_b() {
47*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @fold_from_fp16_to_fp32_b
48*9880d681SAndroid Build Coastguard Worker; CHECK: ret float 4.000000e+00
49*9880d681SAndroid Build Coastguard Workerentry:
50*9880d681SAndroid Build Coastguard Worker  %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0)
51*9880d681SAndroid Build Coastguard Worker  %1 = call float @llvm.convert.from.fp16.f32(i16 %0)
52*9880d681SAndroid Build Coastguard Worker  ret float %1
53*9880d681SAndroid Build Coastguard Worker}
54*9880d681SAndroid Build Coastguard Worker
55*9880d681SAndroid Build Coastguard Workerdefine double @fold_from_fp16_to_fp64_b() {
56*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @fold_from_fp16_to_fp64_b
57*9880d681SAndroid Build Coastguard Worker; CHECK: ret double 4.000000e+00
58*9880d681SAndroid Build Coastguard Workerentry:
59*9880d681SAndroid Build Coastguard Worker  %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0)
60*9880d681SAndroid Build Coastguard Worker  %1 = call double @llvm.convert.from.fp16.f64(i16 %0)
61*9880d681SAndroid Build Coastguard Worker  ret double %1
62*9880d681SAndroid Build Coastguard Worker}
63*9880d681SAndroid Build Coastguard Worker
64*9880d681SAndroid Build Coastguard Workerdefine x86_fp80 @fold_from_fp16_to_fp80_b() {
65*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @fold_from_fp16_to_fp80_b
66*9880d681SAndroid Build Coastguard Worker; CHECK: ret x86_fp80 0xK40018000000000000000
67*9880d681SAndroid Build Coastguard Workerentry:
68*9880d681SAndroid Build Coastguard Worker  %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0)
69*9880d681SAndroid Build Coastguard Worker  %1 = call x86_fp80 @llvm.convert.from.fp16.f80(i16 %0)
70*9880d681SAndroid Build Coastguard Worker  ret x86_fp80 %1
71*9880d681SAndroid Build Coastguard Worker}
72*9880d681SAndroid Build Coastguard Worker
73*9880d681SAndroid Build Coastguard Workerdefine fp128 @fold_from_fp16_to_fp128_b() {
74*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @fold_from_fp16_to_fp128_b
75*9880d681SAndroid Build Coastguard Worker; CHECK: ret fp128 0xL00000000000000004001000000000000
76*9880d681SAndroid Build Coastguard Workerentry:
77*9880d681SAndroid Build Coastguard Worker  %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0)
78*9880d681SAndroid Build Coastguard Worker  %1 = call fp128 @llvm.convert.from.fp16.f128(i16 %0)
79*9880d681SAndroid Build Coastguard Worker  ret fp128 %1
80*9880d681SAndroid Build Coastguard Worker}
81*9880d681SAndroid Build Coastguard Worker
82*9880d681SAndroid Build Coastguard Workerdefine ppc_fp128 @fold_from_fp16_to_ppcfp128_b() {
83*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @fold_from_fp16_to_ppcfp128_b
84*9880d681SAndroid Build Coastguard Worker; CHECK: ret ppc_fp128 0xM40100000000000000000000000000000
85*9880d681SAndroid Build Coastguard Workerentry:
86*9880d681SAndroid Build Coastguard Worker  %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0)
87*9880d681SAndroid Build Coastguard Worker  %1 = call ppc_fp128 @llvm.convert.from.fp16.ppcf128(i16 %0)
88*9880d681SAndroid Build Coastguard Worker  ret ppc_fp128 %1
89*9880d681SAndroid Build Coastguard Worker}
90*9880d681SAndroid Build Coastguard Worker
91*9880d681SAndroid Build Coastguard Worker
92*9880d681SAndroid Build Coastguard Workerdeclare i16 @llvm.convert.to.fp16.f64(double)
93*9880d681SAndroid Build Coastguard Workerdeclare float @llvm.convert.from.fp16.f32(i16)
94*9880d681SAndroid Build Coastguard Workerdeclare double @llvm.convert.from.fp16.f64(i16)
95*9880d681SAndroid Build Coastguard Workerdeclare x86_fp80 @llvm.convert.from.fp16.f80(i16)
96*9880d681SAndroid Build Coastguard Workerdeclare fp128 @llvm.convert.from.fp16.f128(i16)
97*9880d681SAndroid Build Coastguard Workerdeclare ppc_fp128 @llvm.convert.from.fp16.ppcf128(i16)
98