1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -reassociate -gvn -S < %s | FileCheck %s
4 ; (x + 0.1234 * y) * (x + -0.1234 * y) -> (x + 0.1234 * y) * (x - 0.1234 * y)
5 define double @test1(double %x, double %y) {
7 ; CHECK-NEXT: [[MUL:%.*]] = fmul double [[Y:%.*]], 1.234000e-01
8 ; CHECK-NEXT: [[ADD:%.*]] = fadd double [[X:%.*]], [[MUL]]
9 ; CHECK-NEXT: [[ADD21:%.*]] = fsub double [[X]], [[MUL]]
10 ; CHECK-NEXT: [[MUL3:%.*]] = fmul double [[ADD]], [[ADD21]]
11 ; CHECK-NEXT: ret double [[MUL3]]
13 %mul = fmul double 1.234000e-01, %y
14 %add = fadd double %mul, %x
15 %mul1 = fmul double -1.234000e-01, %y
16 %add2 = fadd double %mul1, %x
17 %mul3 = fmul double %add, %add2
21 ; (x + -0.1234 * y) * (x + -0.1234 * y) -> (x - 0.1234 * y) * (x - 0.1234 * y)
22 define double @test2(double %x, double %y) {
23 ; CHECK-LABEL: @test2(
24 ; CHECK-NEXT: [[MUL:%.*]] = fmul double [[Y:%.*]], 1.234000e-01
25 ; CHECK-NEXT: [[ADD1:%.*]] = fsub double [[X:%.*]], [[MUL]]
26 ; CHECK-NEXT: [[MUL3:%.*]] = fmul double [[ADD1]], [[ADD1]]
27 ; CHECK-NEXT: ret double [[MUL3]]
29 %mul = fmul double %y, -1.234000e-01
30 %add = fadd double %mul, %x
31 %mul1 = fmul double %y, -1.234000e-01
32 %add2 = fadd double %mul1, %x
33 %mul3 = fmul double %add, %add2
37 ; (x + 0.1234 * y) * (x - -0.1234 * y) -> (x + 0.1234 * y) * (x + 0.1234 * y)
38 define double @test3(double %x, double %y) {
39 ; CHECK-LABEL: @test3(
40 ; CHECK-NEXT: [[MUL:%.*]] = fmul double [[Y:%.*]], 1.234000e-01
41 ; CHECK-NEXT: [[ADD:%.*]] = fadd double [[X:%.*]], [[MUL]]
42 ; CHECK-NEXT: [[MUL3:%.*]] = fmul double [[ADD]], [[ADD]]
43 ; CHECK-NEXT: ret double [[MUL3]]
45 %mul = fmul double %y, 1.234000e-01
46 %add = fadd double %mul, %x
47 %mul1 = fmul double %y, -1.234000e-01
48 %add2 = fsub double %x, %mul1
49 %mul3 = fmul double %add, %add2
53 ; Canonicalize (x - -0.1234 * y)
54 define double @test5(double %x, double %y) {
55 ; CHECK-LABEL: @test5(
56 ; CHECK-NEXT: [[MUL:%.*]] = fmul double [[Y:%.*]], 1.234000e-01
57 ; CHECK-NEXT: [[SUB1:%.*]] = fadd double [[X:%.*]], [[MUL]]
58 ; CHECK-NEXT: ret double [[SUB1]]
60 %mul = fmul double -1.234000e-01, %y
61 %sub = fsub double %x, %mul
65 ; Don't modify (-0.1234 * y - x)
66 define double @test6(double %x, double %y) {
67 ; CHECK-LABEL: @test6(
68 ; CHECK-NEXT: [[MUL:%.*]] = fmul double [[Y:%.*]], -1.234000e-01
69 ; CHECK-NEXT: [[SUB:%.*]] = fsub double [[MUL]], [[X:%.*]]
70 ; CHECK-NEXT: ret double [[SUB]]
72 %mul = fmul double -1.234000e-01, %y
73 %sub = fsub double %mul, %x
77 ; Canonicalize (-0.1234 * y + x) -> (x - 0.1234 * y)
78 define double @test7(double %x, double %y) {
79 ; CHECK-LABEL: @test7(
80 ; CHECK-NEXT: [[MUL:%.*]] = fmul double [[Y:%.*]], 1.234000e-01
81 ; CHECK-NEXT: [[ADD1:%.*]] = fsub double [[X:%.*]], [[MUL]]
82 ; CHECK-NEXT: ret double [[ADD1]]
84 %mul = fmul double -1.234000e-01, %y
85 %add = fadd double %mul, %x
89 ; Canonicalize (y * -0.1234 + x) -> (x - 0.1234 * y)
90 define double @test8(double %x, double %y) {
91 ; CHECK-LABEL: @test8(
92 ; CHECK-NEXT: [[MUL:%.*]] = fmul double [[Y:%.*]], 1.234000e-01
93 ; CHECK-NEXT: [[ADD1:%.*]] = fsub double [[X:%.*]], [[MUL]]
94 ; CHECK-NEXT: ret double [[ADD1]]
96 %mul = fmul double %y, -1.234000e-01
97 %add = fadd double %mul, %x
101 ; Canonicalize (x - -0.1234 / y)
102 define double @test9(double %x, double %y) {
103 ; CHECK-LABEL: @test9(
104 ; CHECK-NEXT: [[DIV:%.*]] = fdiv double 1.234000e-01, [[Y:%.*]]
105 ; CHECK-NEXT: [[SUB1:%.*]] = fadd double [[X:%.*]], [[DIV]]
106 ; CHECK-NEXT: ret double [[SUB1]]
108 %div = fdiv double -1.234000e-01, %y
109 %sub = fsub double %x, %div
113 ; Don't modify (-0.1234 / y - x)
114 define double @test10(double %x, double %y) {
115 ; CHECK-LABEL: @test10(
116 ; CHECK-NEXT: [[DIV:%.*]] = fdiv double -1.234000e-01, [[Y:%.*]]
117 ; CHECK-NEXT: [[SUB:%.*]] = fsub double [[DIV]], [[X:%.*]]
118 ; CHECK-NEXT: ret double [[SUB]]
120 %div = fdiv double -1.234000e-01, %y
121 %sub = fsub double %div, %x
125 ; Canonicalize (-0.1234 / y + x) -> (x - 0.1234 / y)
126 define double @test11(double %x, double %y) {
127 ; CHECK-LABEL: @test11(
128 ; CHECK-NEXT: [[DIV:%.*]] = fdiv double 1.234000e-01, [[Y:%.*]]
129 ; CHECK-NEXT: [[ADD1:%.*]] = fsub double [[X:%.*]], [[DIV]]
130 ; CHECK-NEXT: ret double [[ADD1]]
132 %div = fdiv double -1.234000e-01, %y
133 %add = fadd double %div, %x
137 ; Canonicalize (y / -0.1234 + x) -> (x - y / 0.1234)
138 define double @test12(double %x, double %y) {
139 ; CHECK-LABEL: @test12(
140 ; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[Y:%.*]], 1.234000e-01
141 ; CHECK-NEXT: [[ADD1:%.*]] = fsub double [[X:%.*]], [[DIV]]
142 ; CHECK-NEXT: ret double [[ADD1]]
144 %div = fdiv double %y, -1.234000e-01
145 %add = fadd double %div, %x
149 ; Don't create an NSW violation
150 define i4 @test13(i4 %x) {
151 ; CHECK-LABEL: @test13(
152 ; CHECK-NEXT: [[MUL:%.*]] = mul nsw i4 [[X:%.*]], -2
153 ; CHECK-NEXT: [[ADD:%.*]] = add i4 [[MUL]], 3
154 ; CHECK-NEXT: ret i4 [[ADD]]
156 %mul = mul nsw i4 %x, -2
157 %add = add i4 %mul, 3
161 ; This tests used to cause an infinite loop where we would loop between
162 ; canonicalizing the negated constant (i.e., (X + Y*-5.0) -> (X - Y*5.0)) and
163 ; breaking up a subtract (i.e., (X - Y*5.0) -> X + (0 - Y*5.0)). To break the
164 ; cycle, we don't canonicalize the negative constant if we're going to later
165 ; break up the subtract.
167 ; Check to make sure we don't canonicalize
168 ; (%pow2*-5.0 + %sub) -> (%sub - %pow2*5.0)
169 ; as we would later break up this subtract causing a cycle.
171 define double @pr34078(double %A) {
172 ; CHECK-LABEL: @pr34078(
173 ; CHECK-NEXT: [[SUB:%.*]] = fsub fast double 1.000000e+00, [[A:%.*]]
174 ; CHECK-NEXT: [[POW2:%.*]] = fmul double [[A]], [[A]]
175 ; CHECK-NEXT: [[MUL5_NEG:%.*]] = fmul fast double [[POW2]], -5.000000e-01
176 ; CHECK-NEXT: [[SUB1:%.*]] = fadd fast double [[MUL5_NEG]], [[SUB]]
177 ; CHECK-NEXT: [[FACTOR:%.*]] = fmul fast double [[SUB1]], 2.000000e+00
178 ; CHECK-NEXT: ret double [[FACTOR]]
180 %sub = fsub fast double 1.000000e+00, %A
181 %pow2 = fmul double %A, %A
182 %mul5 = fmul fast double %pow2, 5.000000e-01
183 %sub1 = fsub fast double %sub, %mul5
184 %add = fadd fast double %sub1, %sub1
188 define double @fadd_fmul_neg_const1(double %a, double %b, double %c) {
189 ; CHECK-LABEL: @fadd_fmul_neg_const1(
190 ; CHECK-NEXT: [[MUL0:%.*]] = fmul double [[B:%.*]], 3.000000e+00
191 ; CHECK-NEXT: [[MUL1:%.*]] = fmul double [[MUL0]], [[C:%.*]]
192 ; CHECK-NEXT: [[TMP1:%.*]] = fsub double [[A:%.*]], [[MUL1]]
193 ; CHECK-NEXT: ret double [[TMP1]]
195 %mul0 = fmul double %b, -3.0
196 %mul1 = fmul double %mul0, %c
197 %add = fadd double %mul1, %a
201 define double @fadd_fmul_neg_const2(double %a, double %b, double %c) {
202 ; CHECK-LABEL: @fadd_fmul_neg_const2(
203 ; CHECK-NEXT: [[MUL0:%.*]] = fmul double [[A:%.*]], 3.000000e+00
204 ; CHECK-NEXT: [[MUL1:%.*]] = fmul double [[MUL0]], [[B:%.*]]
205 ; CHECK-NEXT: [[MUL2:%.*]] = fmul double [[MUL1]], 4.000000e+00
206 ; CHECK-NEXT: [[ADD:%.*]] = fadd double [[A]], [[MUL2]]
207 ; CHECK-NEXT: ret double [[ADD]]
209 %mul0 = fmul double %a, -3.0
210 %mul1 = fmul double %mul0, %b
211 %mul2 = fmul double %mul1, -4.0
212 %add = fadd double %mul2, %a
216 define double @fadd_fmul_neg_const3(double %a, double %b, double %c) {
217 ; CHECK-LABEL: @fadd_fmul_neg_const3(
218 ; CHECK-NEXT: [[MUL0:%.*]] = fmul double [[A:%.*]], 3.000000e+00
219 ; CHECK-NEXT: [[MUL1:%.*]] = fmul double [[MUL0]], [[B:%.*]]
220 ; CHECK-NEXT: [[MUL2:%.*]] = fmul double [[MUL1]], 4.000000e+00
221 ; CHECK-NEXT: [[MUL3:%.*]] = fmul double [[MUL2]], 5.000000e+00
222 ; CHECK-NEXT: [[TMP1:%.*]] = fsub double [[C:%.*]], [[MUL3]]
223 ; CHECK-NEXT: ret double [[TMP1]]
225 %mul0 = fmul double %a, -3.0
226 %mul1 = fmul double %mul0, %b
227 %mul2 = fmul double %mul1, -4.0
228 %mul3 = fmul double %mul2, -5.0
229 %add = fadd double %mul3, %c
233 define double @fsub_fmul_neg_const1(double %a, double %b, double %c) {
234 ; CHECK-LABEL: @fsub_fmul_neg_const1(
235 ; CHECK-NEXT: [[MUL0:%.*]] = fmul double [[B:%.*]], 3.000000e+00
236 ; CHECK-NEXT: [[MUL1:%.*]] = fmul double [[MUL0]], [[C:%.*]]
237 ; CHECK-NEXT: [[TMP1:%.*]] = fadd double [[A:%.*]], [[MUL1]]
238 ; CHECK-NEXT: ret double [[TMP1]]
240 %mul0 = fmul double %b, -3.0
241 %mul1 = fmul double %mul0, %c
242 %sub = fsub double %a, %mul1
246 define double @fsub_fmul_neg_const2(double %a, double %b, double %c) {
247 ; CHECK-LABEL: @fsub_fmul_neg_const2(
248 ; CHECK-NEXT: [[MUL0:%.*]] = fmul double [[A:%.*]], 3.000000e+00
249 ; CHECK-NEXT: [[MUL1:%.*]] = fmul double [[MUL0]], [[B:%.*]]
250 ; CHECK-NEXT: [[MUL2:%.*]] = fmul double [[MUL1]], 4.000000e+00
251 ; CHECK-NEXT: [[TMP1:%.*]] = fadd double [[A]], [[MUL2]]
252 ; CHECK-NEXT: ret double [[TMP1]]
254 %mul0 = fmul double %a, -3.0
255 %mul1 = fmul double %mul0, %b
256 %mul2 = fmul double %mul1, 4.0
257 %sub = fsub double %a, %mul2
261 define double @fsub_fmul_neg_const3(double %a, double %b, double %c) {
262 ; CHECK-LABEL: @fsub_fmul_neg_const3(
263 ; CHECK-NEXT: [[MUL0:%.*]] = fmul double [[A:%.*]], 3.000000e+00
264 ; CHECK-NEXT: [[MUL1:%.*]] = fmul double [[MUL0]], [[B:%.*]]
265 ; CHECK-NEXT: [[MUL2:%.*]] = fmul double [[MUL1]], 4.000000e+00
266 ; CHECK-NEXT: [[MUL3:%.*]] = fmul double [[MUL2]], 5.000000e+00
267 ; CHECK-NEXT: [[SUB:%.*]] = fsub double [[C:%.*]], [[MUL3]]
268 ; CHECK-NEXT: ret double [[SUB]]
270 %mul0 = fmul double %a, 3.0
271 %mul1 = fmul double %mul0, %b
272 %mul2 = fmul double %mul1, -4.0
273 %mul3 = fmul double %mul2, -5.0
274 %sub = fsub double %c, %mul3
278 define double @fadd_fdiv_neg_const1(double %a, double %b, double %c) {
279 ; CHECK-LABEL: @fadd_fdiv_neg_const1(
280 ; CHECK-NEXT: [[DIV0:%.*]] = fdiv double [[B:%.*]], 3.000000e+00
281 ; CHECK-NEXT: [[DIV1:%.*]] = fdiv double [[DIV0]], [[C:%.*]]
282 ; CHECK-NEXT: [[TMP1:%.*]] = fsub double [[A:%.*]], [[DIV1]]
283 ; CHECK-NEXT: ret double [[TMP1]]
285 %div0 = fdiv double %b, -3.0
286 %div1 = fdiv double %div0, %c
287 %add = fadd double %div1, %a
291 define double @fadd_fdiv_neg_const2(double %a, double %b, double %c) {
292 ; CHECK-LABEL: @fadd_fdiv_neg_const2(
293 ; CHECK-NEXT: [[DIV0:%.*]] = fdiv double 3.000000e+00, [[A:%.*]]
294 ; CHECK-NEXT: [[DIV1:%.*]] = fdiv double [[DIV0]], [[B:%.*]]
295 ; CHECK-NEXT: [[DIV2:%.*]] = fdiv double [[DIV1]], 7.000000e+00
296 ; CHECK-NEXT: [[ADD:%.*]] = fadd double [[A]], [[DIV2]]
297 ; CHECK-NEXT: ret double [[ADD]]
299 %div0 = fdiv double -3.0, %a
300 %div1 = fdiv double %div0, %b
301 %div2 = fdiv double %div1, -7.0
302 %add = fadd double %div2, %a
306 define double @fadd_fdiv_neg_const3(double %a, double %b, double %c) {
307 ; CHECK-LABEL: @fadd_fdiv_neg_const3(
308 ; CHECK-NEXT: [[DIV0:%.*]] = fdiv double [[A:%.*]], 3.000000e+00
309 ; CHECK-NEXT: [[DIV1:%.*]] = fdiv double [[DIV0]], [[B:%.*]]
310 ; CHECK-NEXT: [[DIV2:%.*]] = fdiv double 4.000000e+00, [[DIV1]]
311 ; CHECK-NEXT: [[DIV3:%.*]] = fdiv double [[DIV2]], 5.000000e+00
312 ; CHECK-NEXT: [[ADD:%.*]] = fadd double [[C:%.*]], [[DIV3]]
313 ; CHECK-NEXT: ret double [[ADD]]
315 %div0 = fdiv double %a, -3.0
316 %div1 = fdiv double %div0, %b
317 %div2 = fdiv double -4.0, %div1
318 %div3 = fdiv double %div2, 5.0
319 %add = fadd double %div3, %c
323 define double @fsub_fdiv_neg_const1(double %a, double %b, double %c) {
324 ; CHECK-LABEL: @fsub_fdiv_neg_const1(
325 ; CHECK-NEXT: [[DIV0:%.*]] = fdiv double [[B:%.*]], 3.000000e+00
326 ; CHECK-NEXT: [[DIV1:%.*]] = fdiv double [[DIV0]], [[C:%.*]]
327 ; CHECK-NEXT: [[TMP1:%.*]] = fadd double [[A:%.*]], [[DIV1]]
328 ; CHECK-NEXT: ret double [[TMP1]]
330 %div0 = fdiv double %b, -3.0
331 %div1 = fdiv double %div0, %c
332 %sub = fsub double %a, %div1
336 define double @fsub_fdiv_neg_const2(double %a, double %b, double %c) {
337 ; CHECK-LABEL: @fsub_fdiv_neg_const2(
338 ; CHECK-NEXT: [[DIV0:%.*]] = fdiv double 3.000000e+00, [[A:%.*]]
339 ; CHECK-NEXT: [[DIV1:%.*]] = fdiv double [[DIV0]], [[B:%.*]]
340 ; CHECK-NEXT: [[DIV2:%.*]] = fdiv double [[DIV1]], 7.000000e+00
341 ; CHECK-NEXT: [[TMP1:%.*]] = fadd double [[A]], [[DIV2]]
342 ; CHECK-NEXT: ret double [[TMP1]]
344 %div0 = fdiv double -3.0, %a
345 %div1 = fdiv double %div0, %b
346 %div2 = fdiv double %div1, 7.0
347 %sub = fsub double %a, %div2
351 define double @fsub_fdiv_neg_const3(double %a, double %b, double %c) {
352 ; CHECK-LABEL: @fsub_fdiv_neg_const3(
353 ; CHECK-NEXT: [[DIV0:%.*]] = fdiv double 3.000000e+00, [[A:%.*]]
354 ; CHECK-NEXT: [[DIV1:%.*]] = fdiv double [[DIV0]], [[B:%.*]]
355 ; CHECK-NEXT: [[DIV2:%.*]] = fdiv double [[DIV1]], 7.000000e+00
356 ; CHECK-NEXT: [[DIV3:%.*]] = fdiv double 5.000000e+00, [[DIV2]]
357 ; CHECK-NEXT: [[TMP1:%.*]] = fadd double [[C:%.*]], [[DIV3]]
358 ; CHECK-NEXT: ret double [[TMP1]]
360 %div0 = fdiv double -3.0, %a
361 %div1 = fdiv double %div0, %b
362 %div2 = fdiv double %div1, -7.0
363 %div3 = fdiv double -5.0, %div2
364 %sub = fsub double %c, %div3
368 define double @fadd_mix_neg_const1(double %a, double %b, double %c) {
369 ; CHECK-LABEL: @fadd_mix_neg_const1(
370 ; CHECK-NEXT: [[MUL0:%.*]] = fmul double [[B:%.*]], 3.000000e+00
371 ; CHECK-NEXT: [[DIV1:%.*]] = fdiv double [[MUL0]], [[C:%.*]]
372 ; CHECK-NEXT: [[TMP1:%.*]] = fsub double [[A:%.*]], [[DIV1]]
373 ; CHECK-NEXT: ret double [[TMP1]]
375 %mul0 = fmul double %b, -3.0
376 %div1 = fdiv double %mul0, %c
377 %add = fadd double %div1, %a
381 define double @fadd_mix_neg_const2(double %a, double %b, double %c) {
382 ; CHECK-LABEL: @fadd_mix_neg_const2(
383 ; CHECK-NEXT: [[DIV0:%.*]] = fdiv double 3.000000e+00, [[A:%.*]]
384 ; CHECK-NEXT: [[MUL1:%.*]] = fmul double [[DIV0]], [[B:%.*]]
385 ; CHECK-NEXT: [[DIV2:%.*]] = fdiv double [[MUL1]], 5.000000e+00
386 ; CHECK-NEXT: [[ADD:%.*]] = fadd double [[A]], [[DIV2]]
387 ; CHECK-NEXT: ret double [[ADD]]
389 %div0 = fdiv double -3.0, %a
390 %mul1 = fmul double %div0, %b
391 %div2 = fdiv double %mul1, -5.0
392 %add = fadd double %div2, %a
396 define double @fadd_mix_neg_const3(double %a, double %b, double %c) {
397 ; CHECK-LABEL: @fadd_mix_neg_const3(
398 ; CHECK-NEXT: [[MUL0:%.*]] = fmul double [[A:%.*]], 3.000000e+00
399 ; CHECK-NEXT: [[DIV1:%.*]] = fdiv double [[MUL0]], [[B:%.*]]
400 ; CHECK-NEXT: [[MUL2:%.*]] = fmul double [[DIV1]], 4.000000e+00
401 ; CHECK-NEXT: [[DIV3:%.*]] = fdiv double [[MUL2]], 5.000000e+00
402 ; CHECK-NEXT: [[TMP1:%.*]] = fsub double [[C:%.*]], [[DIV3]]
403 ; CHECK-NEXT: ret double [[TMP1]]
405 %mul0 = fmul double %a, -3.0
406 %div1 = fdiv double %mul0, %b
407 %mul2 = fmul double -4.0, %div1
408 %div3 = fdiv double %mul2, -5.0
409 %add = fadd double %div3, %c
413 define double @fsub_mix_neg_const1(double %a, double %b, double %c) {
414 ; CHECK-LABEL: @fsub_mix_neg_const1(
415 ; CHECK-NEXT: [[DIV0:%.*]] = fdiv double [[B:%.*]], 3.000000e+00
416 ; CHECK-NEXT: [[MUL1:%.*]] = fmul double [[DIV0]], [[C:%.*]]
417 ; CHECK-NEXT: [[TMP1:%.*]] = fadd double [[A:%.*]], [[MUL1]]
418 ; CHECK-NEXT: ret double [[TMP1]]
420 %div0 = fdiv double %b, -3.0
421 %mul1 = fmul double %div0, %c
422 %sub = fsub double %a, %mul1
425 define double @fsub_mix_neg_const2(double %a, double %b, double %c) {
426 ; CHECK-LABEL: @fsub_mix_neg_const2(
427 ; CHECK-NEXT: [[MUL0:%.*]] = fmul double [[A:%.*]], 3.000000e+00
428 ; CHECK-NEXT: [[DIV1:%.*]] = fdiv double [[MUL0]], [[B:%.*]]
429 ; CHECK-NEXT: [[MUL2:%.*]] = fmul double [[DIV1]], 5.000000e+00
430 ; CHECK-NEXT: [[SUB:%.*]] = fsub double [[A]], [[MUL2]]
431 ; CHECK-NEXT: ret double [[SUB]]
433 %mul0 = fmul double -3.0, %a
434 %div1 = fdiv double %mul0, %b
435 %mul2 = fmul double %div1, -5.0
436 %sub = fsub double %a, %mul2
440 define double @fsub_mix_neg_const3(double %a, double %b, double %c) {
441 ; CHECK-LABEL: @fsub_mix_neg_const3(
442 ; CHECK-NEXT: [[DIV0:%.*]] = fdiv double 3.000000e+00, [[A:%.*]]
443 ; CHECK-NEXT: [[MUL1:%.*]] = fmul double [[DIV0]], [[B:%.*]]
444 ; CHECK-NEXT: [[DIV2:%.*]] = fdiv double [[MUL1]], 7.000000e+00
445 ; CHECK-NEXT: [[MUL3:%.*]] = fmul double [[DIV2]], 5.000000e+00
446 ; CHECK-NEXT: [[TMP1:%.*]] = fadd double [[C:%.*]], [[MUL3]]
447 ; CHECK-NEXT: ret double [[TMP1]]
449 %div0 = fdiv double -3.0, %a
450 %mul1 = fmul double %div0, %b
451 %div2 = fdiv double %mul1, -7.0
452 %mul3 = fmul double -5.0, %div2
453 %sub = fsub double %c, %mul3
457 define double @fadd_both_ops_mix_neg_const1(double %a, double %b, double %c) {
458 ; CHECK-LABEL: @fadd_both_ops_mix_neg_const1(
459 ; CHECK-NEXT: [[MUL0:%.*]] = fmul double [[B:%.*]], -3.000000e+00
460 ; CHECK-NEXT: [[DIV1:%.*]] = fdiv double [[MUL0]], [[C:%.*]]
461 ; CHECK-NEXT: [[MUL2:%.*]] = fmul double [[A:%.*]], 4.000000e+00
462 ; CHECK-NEXT: [[DIV3:%.*]] = fdiv double [[MUL2]], [[C]]
463 ; CHECK-NEXT: [[TMP1:%.*]] = fsub double [[DIV1]], [[DIV3]]
464 ; CHECK-NEXT: ret double [[TMP1]]
466 %mul0 = fmul double %b, -3.0
467 %div1 = fdiv double %mul0, %c
468 %mul2 = fmul double %a, -4.0
469 %div3 = fdiv double %mul2, %c
470 %add = fadd double %div1, %div3
474 define double @fadd_both_ops_mix_neg_const2(double %a, double %b, double %c) {
475 ; CHECK-LABEL: @fadd_both_ops_mix_neg_const2(
476 ; CHECK-NEXT: [[DIV0:%.*]] = fdiv double 3.000000e+00, [[A:%.*]]
477 ; CHECK-NEXT: [[MUL1:%.*]] = fmul double [[DIV0]], [[B:%.*]]
478 ; CHECK-NEXT: [[DIV2:%.*]] = fdiv double [[MUL1]], 7.000000e+00
479 ; CHECK-NEXT: [[DIV3:%.*]] = fdiv double 5.000000e+00, [[C:%.*]]
480 ; CHECK-NEXT: [[MUL4:%.*]] = fmul double [[B]], [[DIV3]]
481 ; CHECK-NEXT: [[DIV5:%.*]] = fdiv double [[MUL4]], 6.000000e+00
482 ; CHECK-NEXT: [[ADD:%.*]] = fadd double [[DIV2]], [[DIV5]]
483 ; CHECK-NEXT: ret double [[ADD]]
485 %div0 = fdiv double -3.0, %a
486 %mul1 = fmul double %div0, %b
487 %div2 = fdiv double %mul1, -7.0
488 %div3 = fdiv double -5.0, %c
489 %mul4 = fmul double %div3, %b
490 %div5 = fdiv double %mul4, -6.0
491 %add = fadd double %div2, %div5
495 define double @fadd_both_opsmix_neg_const3(double %a, double %b, double %c) {
496 ; CHECK-LABEL: @fadd_both_opsmix_neg_const3(
497 ; CHECK-NEXT: [[MUL0:%.*]] = fmul double [[A:%.*]], -3.000000e+00
498 ; CHECK-NEXT: [[DIV1:%.*]] = fdiv double [[MUL0]], [[B:%.*]]
499 ; CHECK-NEXT: [[MUL2:%.*]] = fmul double [[DIV1]], -4.000000e+00
500 ; CHECK-NEXT: [[DIV3:%.*]] = fdiv double [[MUL2]], -5.000000e+00
501 ; CHECK-NEXT: [[MUL4:%.*]] = fmul double [[C:%.*]], 6.000000e+00
502 ; CHECK-NEXT: [[DIV5:%.*]] = fdiv double [[MUL4]], [[B]]
503 ; CHECK-NEXT: [[MUL6:%.*]] = fmul double [[DIV5]], 7.000000e+00
504 ; CHECK-NEXT: [[MUL7:%.*]] = fdiv double [[MUL6]], 9.000000e+00
505 ; CHECK-NEXT: [[TMP1:%.*]] = fsub double [[DIV3]], [[MUL7]]
506 ; CHECK-NEXT: ret double [[TMP1]]
508 %mul0 = fmul double %a, -3.0
509 %div1 = fdiv double %mul0, %b
510 %mul2 = fmul double -4.0, %div1
511 %div3 = fdiv double %mul2, -5.0
512 %mul4 = fmul double %c, -6.0
513 %div5 = fdiv double %mul4, %b
514 %mul6 = fmul double -7.0, %div5
515 %mul7 = fdiv double %mul6, -9.0
516 %add = fadd double %div3, %mul7