• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -instcombine -S | FileCheck %s
3
4define float @test(float %x) nounwind  {
5; CHECK-LABEL: @test(
6; CHECK-NEXT:  entry:
7; CHECK-NEXT:    [[TMP34:%.*]] = fadd float [[X:%.*]], 0.000000e+00
8; CHECK-NEXT:    ret float [[TMP34]]
9;
10entry:
11  %tmp1 = fpext float %x to double
12  %tmp3 = fadd double %tmp1, 0.000000e+00
13  %tmp34 = fptrunc double %tmp3 to float
14  ret float %tmp34
15}
16
17define float @test2(float %x, float %y) nounwind  {
18; CHECK-LABEL: @test2(
19; CHECK-NEXT:  entry:
20; CHECK-NEXT:    [[TMP56:%.*]] = fmul float [[X:%.*]], [[Y:%.*]]
21; CHECK-NEXT:    ret float [[TMP56]]
22;
23entry:
24  %tmp1 = fpext float %x to double
25  %tmp23 = fpext float %y to double
26  %tmp5 = fmul double %tmp1, %tmp23
27  %tmp56 = fptrunc double %tmp5 to float
28  ret float %tmp56
29}
30
31define float @test3(float %x, float %y) nounwind  {
32; CHECK-LABEL: @test3(
33; CHECK-NEXT:  entry:
34; CHECK-NEXT:    [[TMP56:%.*]] = fdiv float [[X:%.*]], [[Y:%.*]]
35; CHECK-NEXT:    ret float [[TMP56]]
36;
37entry:
38  %tmp1 = fpext float %x to double
39  %tmp23 = fpext float %y to double
40  %tmp5 = fdiv double %tmp1, %tmp23
41  %tmp56 = fptrunc double %tmp5 to float
42  ret float %tmp56
43}
44
45define float @test4(float %x) nounwind  {
46; CHECK-LABEL: @test4(
47; CHECK-NEXT:  entry:
48; CHECK-NEXT:    [[TMP34:%.*]] = fsub float -0.000000e+00, [[X:%.*]]
49; CHECK-NEXT:    ret float [[TMP34]]
50;
51entry:
52  %tmp1 = fpext float %x to double
53  %tmp2 = fsub double -0.000000e+00, %tmp1
54  %tmp34 = fptrunc double %tmp2 to float
55  ret float %tmp34
56}
57
58; Test with vector splat constant
59define <2 x float> @test5(<2 x float> %x) nounwind  {
60; CHECK-LABEL: @test5(
61; CHECK-NEXT:  entry:
62; CHECK-NEXT:    [[TMP34:%.*]] = fadd <2 x float> [[X:%.*]], zeroinitializer
63; CHECK-NEXT:    ret <2 x float> [[TMP34]]
64;
65entry:
66  %tmp1 = fpext <2 x float> %x to <2 x double>
67  %tmp3 = fadd <2 x double> %tmp1, <double 0.000000e+00, double 0.000000e+00>
68  %tmp34 = fptrunc <2 x double> %tmp3 to <2 x float>
69  ret <2 x float> %tmp34
70}
71
72; Test with a non-splat constant
73define <2 x float> @test6(<2 x float> %x) nounwind  {
74; CHECK-LABEL: @test6(
75; CHECK-NEXT:  entry:
76; CHECK-NEXT:    [[TMP34:%.*]] = fadd <2 x float> [[X:%.*]], <float 0.000000e+00, float -0.000000e+00>
77; CHECK-NEXT:    ret <2 x float> [[TMP34]]
78;
79entry:
80  %tmp1 = fpext <2 x float> %x to <2 x double>
81  %tmp3 = fadd <2 x double> %tmp1, <double 0.000000e+00, double -0.000000e+00>
82  %tmp34 = fptrunc <2 x double> %tmp3 to <2 x float>
83  ret <2 x float> %tmp34
84}
85
86; Test with an undef element
87; TODO: Support undef elements.
88define <2 x float> @test6_undef(<2 x float> %x) nounwind  {
89; CHECK-LABEL: @test6_undef(
90; CHECK-NEXT:  entry:
91; CHECK-NEXT:    [[TMP1:%.*]] = fpext <2 x float> [[X:%.*]] to <2 x double>
92; CHECK-NEXT:    [[TMP3:%.*]] = fadd <2 x double> [[TMP1]], <double 0.000000e+00, double undef>
93; CHECK-NEXT:    [[TMP34:%.*]] = fptrunc <2 x double> [[TMP3]] to <2 x float>
94; CHECK-NEXT:    ret <2 x float> [[TMP34]]
95;
96entry:
97  %tmp1 = fpext <2 x float> %x to <2 x double>
98  %tmp3 = fadd <2 x double> %tmp1, <double 0.000000e+00, double undef>
99  %tmp34 = fptrunc <2 x double> %tmp3 to <2 x float>
100  ret <2 x float> %tmp34
101}
102
103define <2 x float> @not_half_shrinkable(<2 x float> %x) {
104; CHECK-LABEL: @not_half_shrinkable(
105; CHECK-NEXT:    [[R:%.*]] = fadd <2 x float> [[X:%.*]], <float 0.000000e+00, float 2.049000e+03>
106; CHECK-NEXT:    ret <2 x float> [[R]]
107;
108  %ext = fpext <2 x float> %x to <2 x double>
109  %add = fadd <2 x double> %ext, <double 0.0, double 2049.0>
110  %r = fptrunc <2 x double> %add to <2 x float>
111  ret <2 x float>  %r
112}
113
114define half @test7(float %a) nounwind {
115; CHECK-LABEL: @test7(
116; CHECK-NEXT:    [[Z:%.*]] = fptrunc float [[A:%.*]] to half
117; CHECK-NEXT:    ret half [[Z]]
118;
119  %y = fpext float %a to double
120  %z = fptrunc double %y to half
121  ret half %z
122}
123
124define float @test8(half %a) nounwind {
125; CHECK-LABEL: @test8(
126; CHECK-NEXT:    [[Z:%.*]] = fpext half [[A:%.*]] to float
127; CHECK-NEXT:    ret float [[Z]]
128;
129  %y = fpext half %a to double
130  %z = fptrunc double %y to float
131  ret float %z
132}
133
134define float @test9(half %x, half %y) nounwind  {
135; CHECK-LABEL: @test9(
136; CHECK-NEXT:  entry:
137; CHECK-NEXT:    [[TMP0:%.*]] = fpext half [[X:%.*]] to float
138; CHECK-NEXT:    [[TMP1:%.*]] = fpext half [[Y:%.*]] to float
139; CHECK-NEXT:    [[TMP56:%.*]] = fmul float [[TMP0]], [[TMP1]]
140; CHECK-NEXT:    ret float [[TMP56]]
141;
142entry:
143  %tmp1 = fpext half %x to double
144  %tmp23 = fpext half %y to double
145  %tmp5 = fmul double %tmp1, %tmp23
146  %tmp56 = fptrunc double %tmp5 to float
147  ret float %tmp56
148}
149
150define float @test10(half %x, float %y) nounwind  {
151; CHECK-LABEL: @test10(
152; CHECK-NEXT:  entry:
153; CHECK-NEXT:    [[TMP0:%.*]] = fpext half [[X:%.*]] to float
154; CHECK-NEXT:    [[TMP56:%.*]] = fmul float [[TMP0]], [[Y:%.*]]
155; CHECK-NEXT:    ret float [[TMP56]]
156;
157entry:
158  %tmp1 = fpext half %x to double
159  %tmp23 = fpext float %y to double
160  %tmp5 = fmul double %tmp1, %tmp23
161  %tmp56 = fptrunc double %tmp5 to float
162  ret float %tmp56
163}
164
165define float @test11(half %x) nounwind  {
166; CHECK-LABEL: @test11(
167; CHECK-NEXT:  entry:
168; CHECK-NEXT:    [[TMP0:%.*]] = fpext half [[X:%.*]] to float
169; CHECK-NEXT:    [[TMP34:%.*]] = fadd float [[TMP0]], 0.000000e+00
170; CHECK-NEXT:    ret float [[TMP34]]
171;
172entry:
173  %tmp1 = fpext half %x to double
174  %tmp3 = fadd double %tmp1, 0.000000e+00
175  %tmp34 = fptrunc double %tmp3 to float
176  ret float %tmp34
177}
178
179define float @test12(float %x, half %y) nounwind  {
180; CHECK-LABEL: @test12(
181; CHECK-NEXT:  entry:
182; CHECK-NEXT:    [[TMP0:%.*]] = fpext half [[Y:%.*]] to float
183; CHECK-NEXT:    [[TMP34:%.*]] = fadd float [[TMP0]], [[X:%.*]]
184; CHECK-NEXT:    ret float [[TMP34]]
185;
186entry:
187  %tmp1 = fpext float %x to double
188  %tmp2 = fpext half %y to double
189  %tmp3 = fadd double %tmp1, %tmp2
190  %tmp34 = fptrunc double %tmp3 to float
191  ret float %tmp34
192}
193
194define float @test13(half %x, float %y) nounwind  {
195; CHECK-LABEL: @test13(
196; CHECK-NEXT:  entry:
197; CHECK-NEXT:    [[TMP0:%.*]] = fpext half [[X:%.*]] to float
198; CHECK-NEXT:    [[TMP56:%.*]] = fdiv float [[TMP0]], [[Y:%.*]]
199; CHECK-NEXT:    ret float [[TMP56]]
200;
201entry:
202  %tmp1 = fpext half %x to double
203  %tmp23 = fpext float %y to double
204  %tmp5 = fdiv double %tmp1, %tmp23
205  %tmp56 = fptrunc double %tmp5 to float
206  ret float %tmp56
207}
208
209define float @test14(float %x, half %y) nounwind  {
210; CHECK-LABEL: @test14(
211; CHECK-NEXT:  entry:
212; CHECK-NEXT:    [[TMP0:%.*]] = fpext half [[Y:%.*]] to float
213; CHECK-NEXT:    [[TMP56:%.*]] = fdiv float [[X:%.*]], [[TMP0]]
214; CHECK-NEXT:    ret float [[TMP56]]
215;
216entry:
217  %tmp1 = fpext float %x to double
218  %tmp23 = fpext half %y to double
219  %tmp5 = fdiv double %tmp1, %tmp23
220  %tmp56 = fptrunc double %tmp5 to float
221  ret float %tmp56
222}
223
224define float @test15(half %x, half %y) nounwind  {
225; CHECK-LABEL: @test15(
226; CHECK-NEXT:  entry:
227; CHECK-NEXT:    [[TMP0:%.*]] = fpext half [[X:%.*]] to float
228; CHECK-NEXT:    [[TMP1:%.*]] = fpext half [[Y:%.*]] to float
229; CHECK-NEXT:    [[TMP56:%.*]] = fdiv float [[TMP0]], [[TMP1]]
230; CHECK-NEXT:    ret float [[TMP56]]
231;
232entry:
233  %tmp1 = fpext half %x to double
234  %tmp23 = fpext half %y to double
235  %tmp5 = fdiv double %tmp1, %tmp23
236  %tmp56 = fptrunc double %tmp5 to float
237  ret float %tmp56
238}
239
240define float @test16(half %x, float %y) nounwind  {
241; CHECK-LABEL: @test16(
242; CHECK-NEXT:  entry:
243; CHECK-NEXT:    [[TMP0:%.*]] = fpext half [[X:%.*]] to float
244; CHECK-NEXT:    [[TMP1:%.*]] = frem float [[TMP0]], [[Y:%.*]]
245; CHECK-NEXT:    ret float [[TMP1]]
246;
247entry:
248  %tmp1 = fpext half %x to double
249  %tmp23 = fpext float %y to double
250  %tmp5 = frem double %tmp1, %tmp23
251  %tmp56 = fptrunc double %tmp5 to float
252  ret float %tmp56
253}
254
255define float @test17(float %x, half %y) nounwind  {
256; CHECK-LABEL: @test17(
257; CHECK-NEXT:  entry:
258; CHECK-NEXT:    [[TMP0:%.*]] = fpext half [[Y:%.*]] to float
259; CHECK-NEXT:    [[TMP1:%.*]] = frem float [[X:%.*]], [[TMP0]]
260; CHECK-NEXT:    ret float [[TMP1]]
261;
262entry:
263  %tmp1 = fpext float %x to double
264  %tmp23 = fpext half %y to double
265  %tmp5 = frem double %tmp1, %tmp23
266  %tmp56 = fptrunc double %tmp5 to float
267  ret float %tmp56
268}
269
270define float @test18(half %x, half %y) nounwind  {
271; CHECK-LABEL: @test18(
272; CHECK-NEXT:  entry:
273; CHECK-NEXT:    [[TMP0:%.*]] = frem half [[X:%.*]], [[Y:%.*]]
274; CHECK-NEXT:    [[TMP56:%.*]] = fpext half [[TMP0]] to float
275; CHECK-NEXT:    ret float [[TMP56]]
276;
277entry:
278  %tmp1 = fpext half %x to double
279  %tmp23 = fpext half %y to double
280  %tmp5 = frem double %tmp1, %tmp23
281  %tmp56 = fptrunc double %tmp5 to float
282  ret float %tmp56
283}
284