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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
| ; RUN: llc -verify-machineinstrs -o - %s -mtriple=arm64-apple-ios7.0 | FileCheck %s
@varhalf = global half 0.0
@varfloat = global float 0.0
@vardouble = global double 0.0
declare float @fabsf(float) readonly
declare double @fabs(double) readonly
declare float @llvm.sqrt.f32(float %Val)
declare double @llvm.sqrt.f64(double %Val)
declare float @ceilf(float) readonly
declare double @ceil(double) readonly
declare float @floorf(float) readonly
declare double @floor(double) readonly
declare float @truncf(float) readonly
declare double @trunc(double) readonly
declare float @rintf(float) readonly
declare double @rint(double) readonly
declare float @nearbyintf(float) readonly
declare double @nearbyint(double) readonly
define void @simple_float() {
; CHECK-LABEL: simple_float:
%val1 = load volatile float, float* @varfloat
%valabs = call float @fabsf(float %val1)
store volatile float %valabs, float* @varfloat
; CHECK: fabs {{s[0-9]+}}, {{s[0-9]+}}
%valneg = fsub float -0.0, %val1
store volatile float %valneg, float* @varfloat
; CHECK: fneg {{s[0-9]+}}, {{s[0-9]+}}
%valsqrt = call float @llvm.sqrt.f32(float %val1)
store volatile float %valsqrt, float* @varfloat
; CHECK: fsqrt {{s[0-9]+}}, {{s[0-9]+}}
%valceil = call float @ceilf(float %val1)
store volatile float %valceil, float* @varfloat
; CHECK: frintp {{s[0-9]+}}, {{s[0-9]+}}
%valfloor = call float @floorf(float %val1)
store volatile float %valfloor, float* @varfloat
; CHECK: frintm {{s[0-9]+}}, {{s[0-9]+}}
%valtrunc = call float @truncf(float %val1)
store volatile float %valtrunc, float* @varfloat
; CHECK: frintz {{s[0-9]+}}, {{s[0-9]+}}
%valrint = call float @rintf(float %val1)
store volatile float %valrint, float* @varfloat
; CHECK: frintx {{s[0-9]+}}, {{s[0-9]+}}
%valnearbyint = call float @nearbyintf(float %val1)
store volatile float %valnearbyint, float* @varfloat
; CHECK: frinti {{s[0-9]+}}, {{s[0-9]+}}
ret void
}
define void @simple_double() {
; CHECK-LABEL: simple_double:
%val1 = load volatile double, double* @vardouble
%valabs = call double @fabs(double %val1)
store volatile double %valabs, double* @vardouble
; CHECK: fabs {{d[0-9]+}}, {{d[0-9]+}}
%valneg = fsub double -0.0, %val1
store volatile double %valneg, double* @vardouble
; CHECK: fneg {{d[0-9]+}}, {{d[0-9]+}}
%valsqrt = call double @llvm.sqrt.f64(double %val1)
store volatile double %valsqrt, double* @vardouble
; CHECK: fsqrt {{d[0-9]+}}, {{d[0-9]+}}
%valceil = call double @ceil(double %val1)
store volatile double %valceil, double* @vardouble
; CHECK: frintp {{d[0-9]+}}, {{d[0-9]+}}
%valfloor = call double @floor(double %val1)
store volatile double %valfloor, double* @vardouble
; CHECK: frintm {{d[0-9]+}}, {{d[0-9]+}}
%valtrunc = call double @trunc(double %val1)
store volatile double %valtrunc, double* @vardouble
; CHECK: frintz {{d[0-9]+}}, {{d[0-9]+}}
%valrint = call double @rint(double %val1)
store volatile double %valrint, double* @vardouble
; CHECK: frintx {{d[0-9]+}}, {{d[0-9]+}}
%valnearbyint = call double @nearbyint(double %val1)
store volatile double %valnearbyint, double* @vardouble
; CHECK: frinti {{d[0-9]+}}, {{d[0-9]+}}
ret void
}
define void @converts() {
; CHECK-LABEL: converts:
%val16 = load volatile half, half* @varhalf
%val32 = load volatile float, float* @varfloat
%val64 = load volatile double, double* @vardouble
%val16to32 = fpext half %val16 to float
store volatile float %val16to32, float* @varfloat
; CHECK: fcvt {{s[0-9]+}}, {{h[0-9]+}}
%val16to64 = fpext half %val16 to double
store volatile double %val16to64, double* @vardouble
; CHECK: fcvt {{d[0-9]+}}, {{h[0-9]+}}
%val32to16 = fptrunc float %val32 to half
store volatile half %val32to16, half* @varhalf
; CHECK: fcvt {{h[0-9]+}}, {{s[0-9]+}}
%val32to64 = fpext float %val32 to double
store volatile double %val32to64, double* @vardouble
; CHECK: fcvt {{d[0-9]+}}, {{s[0-9]+}}
%val64to16 = fptrunc double %val64 to half
store volatile half %val64to16, half* @varhalf
; CHECK: fcvt {{h[0-9]+}}, {{d[0-9]+}}
%val64to32 = fptrunc double %val64 to float
store volatile float %val64to32, float* @varfloat
; CHECK: fcvt {{s[0-9]+}}, {{d[0-9]+}}
ret void
}
|