cos-sin-intrinsic.ll
6.45 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s
declare double @llvm.cos.f64(double %Val)
declare float @llvm.cos.f32(float %Val)
declare <2 x float> @llvm.cos.v2f32(<2 x float> %Val)
declare float @llvm.fabs.f32(float %Val)
declare <2 x float> @llvm.fabs.v2f32(<2 x float> %Val)
define double @undef_arg() {
; CHECK-LABEL: @undef_arg(
; CHECK-NEXT: ret double 0.000000e+00
;
%r = call double @llvm.cos.f64(double undef)
ret double %r
}
define float @undef_arg2(float %d) {
; CHECK-LABEL: @undef_arg2(
; CHECK-NEXT: [[COSVAL:%.*]] = call float @llvm.cos.f32(float [[D:%.*]])
; CHECK-NEXT: [[FSUM:%.*]] = fadd float [[COSVAL]], 0.000000e+00
; CHECK-NEXT: ret float [[FSUM]]
;
%cosval = call float @llvm.cos.f32(float %d)
%cosval2 = call float @llvm.cos.f32(float undef)
%fsum = fadd float %cosval2, %cosval
ret float %fsum
}
define float @fneg_f32(float %x) {
; CHECK-LABEL: @fneg_f32(
; CHECK-NEXT: [[COS:%.*]] = call float @llvm.cos.f32(float [[X:%.*]])
; CHECK-NEXT: ret float [[COS]]
;
%x.fneg = fsub float -0.0, %x
%cos = call float @llvm.cos.f32(float %x.fneg)
ret float %cos
}
define float @unary_fneg_f32(float %x) {
; CHECK-LABEL: @unary_fneg_f32(
; CHECK-NEXT: [[COS:%.*]] = call float @llvm.cos.f32(float [[X:%.*]])
; CHECK-NEXT: ret float [[COS]]
;
%x.fneg = fneg float %x
%cos = call float @llvm.cos.f32(float %x.fneg)
ret float %cos
}
define <2 x float> @fneg_v2f32(<2 x float> %x) {
; CHECK-LABEL: @fneg_v2f32(
; CHECK-NEXT: [[COS:%.*]] = call <2 x float> @llvm.cos.v2f32(<2 x float> [[X:%.*]])
; CHECK-NEXT: ret <2 x float> [[COS]]
;
%x.fneg = fsub <2 x float> <float -0.0, float -0.0>, %x
%cos = call <2 x float> @llvm.cos.v2f32(<2 x float> %x.fneg)
ret <2 x float> %cos
}
define <2 x float> @unary_fneg_v2f32(<2 x float> %x) {
; CHECK-LABEL: @unary_fneg_v2f32(
; CHECK-NEXT: [[COS:%.*]] = call <2 x float> @llvm.cos.v2f32(<2 x float> [[X:%.*]])
; CHECK-NEXT: ret <2 x float> [[COS]]
;
%x.fneg = fneg <2 x float> %x
%cos = call <2 x float> @llvm.cos.v2f32(<2 x float> %x.fneg)
ret <2 x float> %cos
}
; FMF are not required, but they should propagate.
define <2 x float> @fneg_cos_fmf(<2 x float> %x){
; CHECK-LABEL: @fneg_cos_fmf(
; CHECK-NEXT: [[R:%.*]] = call nnan afn <2 x float> @llvm.cos.v2f32(<2 x float> [[X:%.*]])
; CHECK-NEXT: ret <2 x float> [[R]]
;
%negx = fsub fast <2 x float> <float -0.0, float -0.0>, %x
%r = call nnan afn <2 x float> @llvm.cos.v2f32(<2 x float> %negx)
ret <2 x float> %r
}
define <2 x float> @unary_fneg_cos_fmf(<2 x float> %x){
; CHECK-LABEL: @unary_fneg_cos_fmf(
; CHECK-NEXT: [[R:%.*]] = call nnan afn <2 x float> @llvm.cos.v2f32(<2 x float> [[X:%.*]])
; CHECK-NEXT: ret <2 x float> [[R]]
;
%negx = fneg fast <2 x float> %x
%r = call nnan afn <2 x float> @llvm.cos.v2f32(<2 x float> %negx)
ret <2 x float> %r
}
define float @fabs_f32(float %x) {
; CHECK-LABEL: @fabs_f32(
; CHECK-NEXT: [[COS:%.*]] = call float @llvm.cos.f32(float [[X:%.*]])
; CHECK-NEXT: ret float [[COS]]
;
%x.fabs = call float @llvm.fabs.f32(float %x)
%cos = call float @llvm.cos.f32(float %x.fabs)
ret float %cos
}
define float @fabs_fneg_f32(float %x) {
; CHECK-LABEL: @fabs_fneg_f32(
; CHECK-NEXT: [[COS:%.*]] = call float @llvm.cos.f32(float [[X:%.*]])
; CHECK-NEXT: ret float [[COS]]
;
%x.fabs = call float @llvm.fabs.f32(float %x)
%x.fabs.fneg = fsub float -0.0, %x.fabs
%cos = call float @llvm.cos.f32(float %x.fabs.fneg)
ret float %cos
}
define float @fabs_unary_fneg_f32(float %x) {
; CHECK-LABEL: @fabs_unary_fneg_f32(
; CHECK-NEXT: [[COS:%.*]] = call float @llvm.cos.f32(float [[X:%.*]])
; CHECK-NEXT: ret float [[COS]]
;
%x.fabs = call float @llvm.fabs.f32(float %x)
%x.fabs.fneg = fneg float %x.fabs
%cos = call float @llvm.cos.f32(float %x.fabs.fneg)
ret float %cos
}
define <2 x float> @fabs_fneg_v2f32(<2 x float> %x) {
; CHECK-LABEL: @fabs_fneg_v2f32(
; CHECK-NEXT: [[COS:%.*]] = call <2 x float> @llvm.cos.v2f32(<2 x float> [[X:%.*]])
; CHECK-NEXT: ret <2 x float> [[COS]]
;
%x.fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %x)
%x.fabs.fneg = fsub <2 x float> <float -0.0, float -0.0>, %x.fabs
%cos = call <2 x float> @llvm.cos.v2f32(<2 x float> %x.fabs.fneg)
ret <2 x float> %cos
}
define <2 x float> @fabs_unary_fneg_v2f32(<2 x float> %x) {
; CHECK-LABEL: @fabs_unary_fneg_v2f32(
; CHECK-NEXT: [[COS:%.*]] = call <2 x float> @llvm.cos.v2f32(<2 x float> [[X:%.*]])
; CHECK-NEXT: ret <2 x float> [[COS]]
;
%x.fabs = call <2 x float> @llvm.fabs.v2f32(<2 x float> %x)
%x.fabs.fneg = fneg <2 x float> %x.fabs
%cos = call <2 x float> @llvm.cos.v2f32(<2 x float> %x.fabs.fneg)
ret <2 x float> %cos
}
; Negate is canonicalized after sin.
declare <2 x float> @llvm.sin.v2f32(<2 x float>)
define <2 x float> @fneg_sin(<2 x float> %x){
; CHECK-LABEL: @fneg_sin(
; CHECK-NEXT: [[TMP1:%.*]] = call <2 x float> @llvm.sin.v2f32(<2 x float> [[X:%.*]])
; CHECK-NEXT: [[R:%.*]] = fneg <2 x float> [[TMP1]]
; CHECK-NEXT: ret <2 x float> [[R]]
;
%negx = fsub <2 x float> <float -0.0, float -0.0>, %x
%r = call <2 x float> @llvm.sin.v2f32(<2 x float> %negx)
ret <2 x float> %r
}
define <2 x float> @unary_fneg_sin(<2 x float> %x){
; CHECK-LABEL: @unary_fneg_sin(
; CHECK-NEXT: [[TMP1:%.*]] = call <2 x float> @llvm.sin.v2f32(<2 x float> [[X:%.*]])
; CHECK-NEXT: [[R:%.*]] = fneg <2 x float> [[TMP1]]
; CHECK-NEXT: ret <2 x float> [[R]]
;
%negx = fneg <2 x float> %x
%r = call <2 x float> @llvm.sin.v2f32(<2 x float> %negx)
ret <2 x float> %r
}
; FMF are not required, but they should propagate.
define <2 x float> @fneg_sin_fmf(<2 x float> %x){
; CHECK-LABEL: @fneg_sin_fmf(
; CHECK-NEXT: [[TMP1:%.*]] = call nnan arcp afn <2 x float> @llvm.sin.v2f32(<2 x float> [[X:%.*]])
; CHECK-NEXT: [[R:%.*]] = fneg nnan arcp afn <2 x float> [[TMP1]]
; CHECK-NEXT: ret <2 x float> [[R]]
;
%negx = fsub fast <2 x float> <float -0.0, float -0.0>, %x
%r = call nnan arcp afn <2 x float> @llvm.sin.v2f32(<2 x float> %negx)
ret <2 x float> %r
}
define <2 x float> @unary_fneg_sin_fmf(<2 x float> %x){
; CHECK-LABEL: @unary_fneg_sin_fmf(
; CHECK-NEXT: [[TMP1:%.*]] = call nnan arcp afn <2 x float> @llvm.sin.v2f32(<2 x float> [[X:%.*]])
; CHECK-NEXT: [[R:%.*]] = fneg nnan arcp afn <2 x float> [[TMP1]]
; CHECK-NEXT: ret <2 x float> [[R]]
;
%negx = fneg fast <2 x float> %x
%r = call nnan arcp afn <2 x float> @llvm.sin.v2f32(<2 x float> %negx)
ret <2 x float> %r
}