File: convert-from-fp16.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (97 lines) | stat: -rw-r--r-- 2,902 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
; RUN: opt -instsimplify -S < %s | FileCheck %s

; Verify that we don't crash with an assertion failure when constant folding
; a call to intrinsic 'convert.from.fp16' if the return type is not 'float'.

define float @fold_from_fp16_to_fp32() {
; CHECK-LABEL: @fold_from_fp16_to_fp32
; CHECK: ret float 0.000000e+00
entry:
  %0 = call float @llvm.convert.from.fp16.f32(i16 0)
  ret float %0
}

define double @fold_from_fp16_to_fp64() {
; CHECK-LABEL: @fold_from_fp16_to_fp64
; CHECK: ret double 0.000000e+00
entry:
  %0 = call double @llvm.convert.from.fp16.f64(i16 0)
  ret double %0
}

define x86_fp80 @fold_from_fp16_to_fp80() {
; CHECK-LABEL: @fold_from_fp16_to_fp80
; CHECK: ret x86_fp80 0xK00000000000000000000
entry:
  %0 = call x86_fp80 @llvm.convert.from.fp16.f80(i16 0)
  ret x86_fp80 %0
}

define fp128 @fold_from_fp16_to_fp128() {
; CHECK-LABEL: @fold_from_fp16_to_fp128
; CHECK: ret fp128 0xL00000000000000000000000000000000
entry:
  %0 = call fp128 @llvm.convert.from.fp16.f128(i16 0)
  ret fp128 %0
}

define ppc_fp128 @fold_from_fp16_to_ppcfp128() {
; CHECK-LABEL: @fold_from_fp16_to_ppcfp128
; CHECK: ret ppc_fp128 0xM00000000000000000000000000000000
entry:
  %0 = call ppc_fp128 @llvm.convert.from.fp16.ppcf128(i16 0)
  ret ppc_fp128 %0
}

define float @fold_from_fp16_to_fp32_b() {
; CHECK-LABEL: @fold_from_fp16_to_fp32_b
; CHECK: ret float 4.000000e+00
entry:
  %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0)
  %1 = call float @llvm.convert.from.fp16.f32(i16 %0)
  ret float %1
}

define double @fold_from_fp16_to_fp64_b() {
; CHECK-LABEL: @fold_from_fp16_to_fp64_b
; CHECK: ret double 4.000000e+00
entry:
  %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0)
  %1 = call double @llvm.convert.from.fp16.f64(i16 %0)
  ret double %1
}

define x86_fp80 @fold_from_fp16_to_fp80_b() {
; CHECK-LABEL: @fold_from_fp16_to_fp80_b
; CHECK: ret x86_fp80 0xK40018000000000000000
entry:
  %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0)
  %1 = call x86_fp80 @llvm.convert.from.fp16.f80(i16 %0)
  ret x86_fp80 %1
}

define fp128 @fold_from_fp16_to_fp128_b() {
; CHECK-LABEL: @fold_from_fp16_to_fp128_b
; CHECK: ret fp128 0xL00000000000000004001000000000000
entry:
  %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0)
  %1 = call fp128 @llvm.convert.from.fp16.f128(i16 %0)
  ret fp128 %1
}

define ppc_fp128 @fold_from_fp16_to_ppcfp128_b() {
; CHECK-LABEL: @fold_from_fp16_to_ppcfp128_b
; CHECK: ret ppc_fp128 0xM40100000000000000000000000000000
entry:
  %0 = call i16 @llvm.convert.to.fp16.f64(double 4.0)
  %1 = call ppc_fp128 @llvm.convert.from.fp16.ppcf128(i16 %0)
  ret ppc_fp128 %1
}


declare i16 @llvm.convert.to.fp16.f64(double)
declare float @llvm.convert.from.fp16.f32(i16)
declare double @llvm.convert.from.fp16.f64(i16)
declare x86_fp80 @llvm.convert.from.fp16.f80(i16)
declare fp128 @llvm.convert.from.fp16.f128(i16)
declare ppc_fp128 @llvm.convert.from.fp16.ppcf128(i16)