fpextend.ll
7.84 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s
define float @test(float %x) nounwind {
; CHECK-LABEL: @test(
; CHECK-NEXT: [[T34:%.*]] = fadd float [[X:%.*]], 0.000000e+00
; CHECK-NEXT: ret float [[T34]]
;
%t1 = fpext float %x to double
%t3 = fadd double %t1, 0.000000e+00
%t34 = fptrunc double %t3 to float
ret float %t34
}
define float @test2(float %x, float %y) nounwind {
; CHECK-LABEL: @test2(
; CHECK-NEXT: [[T56:%.*]] = fmul float [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: ret float [[T56]]
;
%t1 = fpext float %x to double
%t23 = fpext float %y to double
%t5 = fmul double %t1, %t23
%t56 = fptrunc double %t5 to float
ret float %t56
}
define float @test3(float %x, float %y) nounwind {
; CHECK-LABEL: @test3(
; CHECK-NEXT: [[T56:%.*]] = fdiv float [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: ret float [[T56]]
;
%t1 = fpext float %x to double
%t23 = fpext float %y to double
%t5 = fdiv double %t1, %t23
%t56 = fptrunc double %t5 to float
ret float %t56
}
define float @test4(float %x) nounwind {
; CHECK-LABEL: @test4(
; CHECK-NEXT: [[T34:%.*]] = fsub float -0.000000e+00, [[X:%.*]]
; CHECK-NEXT: ret float [[T34]]
;
%t1 = fpext float %x to double
%t2 = fsub double -0.000000e+00, %t1
%t34 = fptrunc double %t2 to float
ret float %t34
}
define float @test4_unary_fneg(float %x) nounwind {
; CHECK-LABEL: @test4_unary_fneg(
; CHECK-NEXT: [[T34:%.*]] = fneg float [[X:%.*]]
; CHECK-NEXT: ret float [[T34]]
;
%t1 = fpext float %x to double
%t2 = fneg double %t1
%t34 = fptrunc double %t2 to float
ret float %t34
}
; Test with vector splat constant
define <2 x float> @test5(<2 x float> %x) nounwind {
; CHECK-LABEL: @test5(
; CHECK-NEXT: [[T34:%.*]] = fadd <2 x float> [[X:%.*]], zeroinitializer
; CHECK-NEXT: ret <2 x float> [[T34]]
;
%t1 = fpext <2 x float> %x to <2 x double>
%t3 = fadd <2 x double> %t1, <double 0.000000e+00, double 0.000000e+00>
%t34 = fptrunc <2 x double> %t3 to <2 x float>
ret <2 x float> %t34
}
; Test with a non-splat constant
define <2 x float> @test6(<2 x float> %x) nounwind {
; CHECK-LABEL: @test6(
; CHECK-NEXT: [[T34:%.*]] = fadd <2 x float> [[X:%.*]], <float 0.000000e+00, float -0.000000e+00>
; CHECK-NEXT: ret <2 x float> [[T34]]
;
%t1 = fpext <2 x float> %x to <2 x double>
%t3 = fadd <2 x double> %t1, <double 0.000000e+00, double -0.000000e+00>
%t34 = fptrunc <2 x double> %t3 to <2 x float>
ret <2 x float> %t34
}
; Test with an undef element
; TODO: Support undef elements.
define <2 x float> @test6_undef(<2 x float> %x) nounwind {
; CHECK-LABEL: @test6_undef(
; CHECK-NEXT: [[T1:%.*]] = fpext <2 x float> [[X:%.*]] to <2 x double>
; CHECK-NEXT: [[T3:%.*]] = fadd <2 x double> [[T1]], <double 0.000000e+00, double undef>
; CHECK-NEXT: [[T34:%.*]] = fptrunc <2 x double> [[T3]] to <2 x float>
; CHECK-NEXT: ret <2 x float> [[T34]]
;
%t1 = fpext <2 x float> %x to <2 x double>
%t3 = fadd <2 x double> %t1, <double 0.000000e+00, double undef>
%t34 = fptrunc <2 x double> %t3 to <2 x float>
ret <2 x float> %t34
}
define <2 x float> @not_half_shrinkable(<2 x float> %x) {
; CHECK-LABEL: @not_half_shrinkable(
; CHECK-NEXT: [[R:%.*]] = fadd <2 x float> [[X:%.*]], <float 0.000000e+00, float 2.049000e+03>
; CHECK-NEXT: ret <2 x float> [[R]]
;
%ext = fpext <2 x float> %x to <2 x double>
%add = fadd <2 x double> %ext, <double 0.0, double 2049.0>
%r = fptrunc <2 x double> %add to <2 x float>
ret <2 x float> %r
}
define half @test7(float %a) nounwind {
; CHECK-LABEL: @test7(
; CHECK-NEXT: [[Z:%.*]] = fptrunc float [[A:%.*]] to half
; CHECK-NEXT: ret half [[Z]]
;
%y = fpext float %a to double
%z = fptrunc double %y to half
ret half %z
}
define float @test8(half %a) nounwind {
; CHECK-LABEL: @test8(
; CHECK-NEXT: [[Z:%.*]] = fpext half [[A:%.*]] to float
; CHECK-NEXT: ret float [[Z]]
;
%y = fpext half %a to double
%z = fptrunc double %y to float
ret float %z
}
define float @test9(half %x, half %y) nounwind {
; CHECK-LABEL: @test9(
; CHECK-NEXT: [[TMP1:%.*]] = fpext half [[X:%.*]] to float
; CHECK-NEXT: [[TMP2:%.*]] = fpext half [[Y:%.*]] to float
; CHECK-NEXT: [[T56:%.*]] = fmul float [[TMP1]], [[TMP2]]
; CHECK-NEXT: ret float [[T56]]
;
%t1 = fpext half %x to double
%t23 = fpext half %y to double
%t5 = fmul double %t1, %t23
%t56 = fptrunc double %t5 to float
ret float %t56
}
define float @test10(half %x, float %y) nounwind {
; CHECK-LABEL: @test10(
; CHECK-NEXT: [[TMP1:%.*]] = fpext half [[X:%.*]] to float
; CHECK-NEXT: [[T56:%.*]] = fmul float [[TMP1]], [[Y:%.*]]
; CHECK-NEXT: ret float [[T56]]
;
%t1 = fpext half %x to double
%t23 = fpext float %y to double
%t5 = fmul double %t1, %t23
%t56 = fptrunc double %t5 to float
ret float %t56
}
define float @test11(half %x) nounwind {
; CHECK-LABEL: @test11(
; CHECK-NEXT: [[TMP1:%.*]] = fpext half [[X:%.*]] to float
; CHECK-NEXT: [[T34:%.*]] = fadd float [[TMP1]], 0.000000e+00
; CHECK-NEXT: ret float [[T34]]
;
%t1 = fpext half %x to double
%t3 = fadd double %t1, 0.000000e+00
%t34 = fptrunc double %t3 to float
ret float %t34
}
define float @test12(float %x, half %y) nounwind {
; CHECK-LABEL: @test12(
; CHECK-NEXT: [[TMP1:%.*]] = fpext half [[Y:%.*]] to float
; CHECK-NEXT: [[T34:%.*]] = fadd float [[TMP1]], [[X:%.*]]
; CHECK-NEXT: ret float [[T34]]
;
%t1 = fpext float %x to double
%t2 = fpext half %y to double
%t3 = fadd double %t1, %t2
%t34 = fptrunc double %t3 to float
ret float %t34
}
define float @test13(half %x, float %y) nounwind {
; CHECK-LABEL: @test13(
; CHECK-NEXT: [[TMP1:%.*]] = fpext half [[X:%.*]] to float
; CHECK-NEXT: [[T56:%.*]] = fdiv float [[TMP1]], [[Y:%.*]]
; CHECK-NEXT: ret float [[T56]]
;
%t1 = fpext half %x to double
%t23 = fpext float %y to double
%t5 = fdiv double %t1, %t23
%t56 = fptrunc double %t5 to float
ret float %t56
}
define float @test14(float %x, half %y) nounwind {
; CHECK-LABEL: @test14(
; CHECK-NEXT: [[TMP1:%.*]] = fpext half [[Y:%.*]] to float
; CHECK-NEXT: [[T56:%.*]] = fdiv float [[X:%.*]], [[TMP1]]
; CHECK-NEXT: ret float [[T56]]
;
%t1 = fpext float %x to double
%t23 = fpext half %y to double
%t5 = fdiv double %t1, %t23
%t56 = fptrunc double %t5 to float
ret float %t56
}
define float @test15(half %x, half %y) nounwind {
; CHECK-LABEL: @test15(
; CHECK-NEXT: [[TMP1:%.*]] = fpext half [[X:%.*]] to float
; CHECK-NEXT: [[TMP2:%.*]] = fpext half [[Y:%.*]] to float
; CHECK-NEXT: [[T56:%.*]] = fdiv float [[TMP1]], [[TMP2]]
; CHECK-NEXT: ret float [[T56]]
;
%t1 = fpext half %x to double
%t23 = fpext half %y to double
%t5 = fdiv double %t1, %t23
%t56 = fptrunc double %t5 to float
ret float %t56
}
define float @test16(half %x, float %y) nounwind {
; CHECK-LABEL: @test16(
; CHECK-NEXT: [[TMP1:%.*]] = fpext half [[X:%.*]] to float
; CHECK-NEXT: [[TMP2:%.*]] = frem float [[TMP1]], [[Y:%.*]]
; CHECK-NEXT: ret float [[TMP2]]
;
%t1 = fpext half %x to double
%t23 = fpext float %y to double
%t5 = frem double %t1, %t23
%t56 = fptrunc double %t5 to float
ret float %t56
}
define float @test17(float %x, half %y) nounwind {
; CHECK-LABEL: @test17(
; CHECK-NEXT: [[TMP1:%.*]] = fpext half [[Y:%.*]] to float
; CHECK-NEXT: [[TMP2:%.*]] = frem float [[X:%.*]], [[TMP1]]
; CHECK-NEXT: ret float [[TMP2]]
;
%t1 = fpext float %x to double
%t23 = fpext half %y to double
%t5 = frem double %t1, %t23
%t56 = fptrunc double %t5 to float
ret float %t56
}
define float @test18(half %x, half %y) nounwind {
; CHECK-LABEL: @test18(
; CHECK-NEXT: [[TMP1:%.*]] = frem half [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[T56:%.*]] = fpext half [[TMP1]] to float
; CHECK-NEXT: ret float [[T56]]
;
%t1 = fpext half %x to double
%t23 = fpext half %y to double
%t5 = frem double %t1, %t23
%t56 = fptrunc double %t5 to float
ret float %t56
}