llvm.org GIT mirror llvm / d79d666
[Reassociate] regenerate checks; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326511 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 2 years ago
1 changed file(s) with 62 addition(s) and 61 deletion(s). Raw diff Collapse all Expand all
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1 ; RUN: opt < %s -reassociate -gvn -instcombine -S | FileCheck %s
12
23 ; With reassociation, constant folding can eliminate the 12 and -12 constants.
34 define float @test1(float %arg) {
45 ; CHECK-LABEL: @test1(
5 ; CHECK-NEXT: [[ARG_NEG:%.*]] = fsub fast float -0.000000e+00, %arg
6 ; CHECK-NEXT: [[ARG_NEG:%.*]] = fsub fast float -0.000000e+00, [[ARG:%.*]]
67 ; CHECK-NEXT: ret float [[ARG_NEG]]
78 ;
89 %t1 = fsub fast float -1.200000e+01, %arg
1213
1314 define float @test1_reassoc(float %arg) {
1415 ; CHECK-LABEL: @test1_reassoc(
15 ; CHECK-NEXT: [[T1:%.*]] = fsub reassoc float -1.200000e+01, %arg
16 ; CHECK-NEXT: [[T1:%.*]] = fsub reassoc float -1.200000e+01, [[ARG:%.*]]
1617 ; CHECK-NEXT: [[T2:%.*]] = fadd reassoc float [[T1]], 1.200000e+01
1718 ; CHECK-NEXT: ret float [[T2]]
1819 ;
2324
2425 define float @test2(float %reg109, float %reg1111) {
2526 ; CHECK-LABEL: @test2(
26 ; CHECK-NEXT: [[REG115:%.*]] = fadd float %reg109, -3.000000e+01
27 ; CHECK-NEXT: [[REG116:%.*]] = fadd float [[REG115]], %reg1111
27 ; CHECK-NEXT: [[REG115:%.*]] = fadd float [[REG109:%.*]], -3.000000e+01
28 ; CHECK-NEXT: [[REG116:%.*]] = fadd float [[REG115]], [[REG1111:%.*]]
2829 ; CHECK-NEXT: [[REG117:%.*]] = fadd float [[REG116]], 3.000000e+01
2930 ; CHECK-NEXT: ret float [[REG117]]
3031 ;
3637
3738 define float @test3(float %reg109, float %reg1111) {
3839 ; CHECK-LABEL: @test3(
39 ; CHECK-NEXT: [[REG117:%.*]] = fadd fast float %reg109, %reg1111
40 ; CHECK-NEXT: [[REG117:%.*]] = fadd fast float [[REG109:%.*]], [[REG1111:%.*]]
4041 ; CHECK-NEXT: ret float [[REG117]]
4142 ;
4243 %reg115 = fadd fast float %reg109, -3.000000e+01
4748
4849 define float @test3_reassoc(float %reg109, float %reg1111) {
4950 ; CHECK-LABEL: @test3_reassoc(
50 ; CHECK-NEXT: [[REG115:%.*]] = fadd reassoc float %reg109, -3.000000e+01
51 ; CHECK-NEXT: [[REG116:%.*]] = fadd reassoc float [[REG115]], %reg1111
51 ; CHECK-NEXT: [[REG115:%.*]] = fadd reassoc float [[REG109:%.*]], -3.000000e+01
52 ; CHECK-NEXT: [[REG116:%.*]] = fadd reassoc float [[REG115]], [[REG1111:%.*]]
5253 ; CHECK-NEXT: [[REG117:%.*]] = fadd reassoc float [[REG116]], 3.000000e+01
5354 ; CHECK-NEXT: ret float [[REG117]]
5455 ;
141142
142143 define float @test7(float %A, float %B, float %C) {
143144 ; CHECK-LABEL: @test7(
144 ; CHECK-NEXT: [[REASS_ADD1:%.*]] = fadd fast float %C, %B
145 ; CHECK-NEXT: [[REASS_MUL2:%.*]] = fmul fast float %A, %A
146 ; CHECK-NEXT: [[REASS_MUL:%.*]] = fmul fast float [[REASS_MUL:%.*]]2, [[REASS_ADD1]]
145 ; CHECK-NEXT: [[REASS_ADD1:%.*]] = fadd fast float [[C:%.*]], [[B:%.*]]
146 ; CHECK-NEXT: [[REASS_MUL2:%.*]] = fmul fast float [[A:%.*]], [[A]]
147 ; CHECK-NEXT: [[REASS_MUL:%.*]] = fmul fast float [[REASS_MUL2]], [[REASS_ADD1]]
147148 ; CHECK-NEXT: ret float [[REASS_MUL]]
148149 ;
149150 %aa = fmul fast float %A, %A
156157
157158 define float @test7_reassoc(float %A, float %B, float %C) {
158159 ; CHECK-LABEL: @test7_reassoc(
159 ; CHECK-NEXT: [[AA:%.*]] = fmul reassoc float %A, %A
160 ; CHECK-NEXT: [[AAB:%.*]] = fmul reassoc float [[AA]], %B
161 ; CHECK-NEXT: [[AC:%.*]] = fmul reassoc float %A, %C
162 ; CHECK-NEXT: [[AAC:%.*]] = fmul reassoc float [[AC]], %A
160 ; CHECK-NEXT: [[AA:%.*]] = fmul reassoc float [[A:%.*]], [[A]]
161 ; CHECK-NEXT: [[AAB:%.*]] = fmul reassoc float [[AA]], [[B:%.*]]
162 ; CHECK-NEXT: [[AC:%.*]] = fmul reassoc float [[A]], [[C:%.*]]
163 ; CHECK-NEXT: [[AAC:%.*]] = fmul reassoc float [[AC]], [[A]]
163164 ; CHECK-NEXT: [[R:%.*]] = fadd reassoc float [[AAB]], [[AAC]]
164165 ; CHECK-NEXT: ret float [[R]]
165166 ;
175176
176177 define float @test8(float %X, float %Y, float %Z) {
177178 ; CHECK-LABEL: @test8(
178 ; CHECK-NEXT: [[A:%.*]] = fmul fast float %Y, %X
179 ; CHECK-NEXT: [[C:%.*]] = fsub fast float %Z, [[A]]
179 ; CHECK-NEXT: [[A:%.*]] = fmul fast float [[Y:%.*]], [[X:%.*]]
180 ; CHECK-NEXT: [[C:%.*]] = fsub fast float [[Z:%.*]], [[A]]
180181 ; CHECK-NEXT: ret float [[C]]
181182 ;
182183 %A = fsub fast float 0.0, %X
187188
188189 define float @test8_reassoc(float %X, float %Y, float %Z) {
189190 ; CHECK-LABEL: @test8_reassoc(
190 ; CHECK-NEXT: [[A:%.*]] = fsub reassoc float 0.000000e+00, %X
191 ; CHECK-NEXT: [[B:%.*]] = fmul reassoc float [[A]], %Y
192 ; CHECK-NEXT: [[C:%.*]] = fadd reassoc float [[B]], %Z
191 ; CHECK-NEXT: [[A:%.*]] = fsub reassoc float 0.000000e+00, [[X:%.*]]
192 ; CHECK-NEXT: [[B:%.*]] = fmul reassoc float [[A]], [[Y:%.*]]
193 ; CHECK-NEXT: [[C:%.*]] = fadd reassoc float [[B]], [[Z:%.*]]
193194 ; CHECK-NEXT: ret float [[C]]
194195 ;
195196 %A = fsub reassoc float 0.0, %X
200201
201202 define float @test9(float %X) {
202203 ; CHECK-LABEL: @test9(
203 ; CHECK-NEXT: [[FACTOR:%.*]] = fmul fast float %X, 9.400000e+01
204 ; CHECK-NEXT: [[FACTOR:%.*]] = fmul fast float [[X:%.*]], 9.400000e+01
204205 ; CHECK-NEXT: ret float [[FACTOR]]
205206 ;
206207 %Y = fmul fast float %X, 4.700000e+01
210211
211212 define float @test9_reassoc(float %X) {
212213 ; CHECK-LABEL: @test9_reassoc(
213 ; CHECK-NEXT: [[Y:%.*]] = fmul reassoc float %X, 4.700000e+01
214 ; CHECK-NEXT: [[Y:%.*]] = fmul reassoc float [[X:%.*]], 4.700000e+01
214215 ; CHECK-NEXT: [[Z:%.*]] = fadd reassoc float [[Y]], [[Y]]
215216 ; CHECK-NEXT: ret float [[Z]]
216217 ;
221222
222223 define float @test10(float %X) {
223224 ; CHECK-LABEL: @test10(
224 ; CHECK-NEXT: [[FACTOR:%.*]] = fmul fast float %X, 3.000000e+00
225 ; CHECK-NEXT: [[FACTOR:%.*]] = fmul fast float [[X:%.*]], 3.000000e+00
225226 ; CHECK-NEXT: ret float [[FACTOR]]
226227 ;
227228 %Y = fadd fast float %X ,%X
231232
232233 define float @test10_reassoc(float %X) {
233234 ; CHECK-LABEL: @test10_reassoc(
234 ; CHECK-NEXT: [[Y:%.*]] = fadd reassoc float %X, %X
235 ; CHECK-NEXT: [[Z:%.*]] = fadd reassoc float [[Y]], %X
235 ; CHECK-NEXT: [[Y:%.*]] = fadd reassoc float [[X:%.*]], [[X]]
236 ; CHECK-NEXT: [[Z:%.*]] = fadd reassoc float [[Y]], [[X]]
236237 ; CHECK-NEXT: ret float [[Z]]
237238 ;
238239 %Y = fadd reassoc float %X ,%X
242243
243244 define float @test11(float %W) {
244245 ; CHECK-LABEL: @test11(
245 ; CHECK-NEXT: [[FACTOR:%.*]] = fmul fast float %W, 3.810000e+02
246 ; CHECK-NEXT: [[FACTOR:%.*]] = fmul fast float [[W:%.*]], 3.810000e+02
246247 ; CHECK-NEXT: ret float [[FACTOR]]
247248 ;
248249 %X = fmul fast float %W, 127.0
253254
254255 define float @test11_reassoc(float %W) {
255256 ; CHECK-LABEL: @test11_reassoc(
256 ; CHECK-NEXT: [[X:%.*]] = fmul reassoc float %W, 1.270000e+02
257 ; CHECK-NEXT: [[X:%.*]] = fmul reassoc float [[W:%.*]], 1.270000e+02
257258 ; CHECK-NEXT: [[Y:%.*]] = fadd reassoc float [[X]], [[X]]
258259 ; CHECK-NEXT: [[Z:%.*]] = fadd reassoc float [[X]], [[Y]]
259260 ; CHECK-NEXT: ret float [[Z]]
266267
267268 define float @test12(float %X) {
268269 ; CHECK-LABEL: @test12(
269 ; CHECK-NEXT: [[FACTOR:%.*]] = fmul fast float %X, -3.000000e+00
270 ; CHECK-NEXT: [[FACTOR:%.*]] = fmul fast float [[X:%.*]], -3.000000e+00
270271 ; CHECK-NEXT: [[Z:%.*]] = fadd fast float [[FACTOR]], 6.000000e+00
271272 ; CHECK-NEXT: ret float [[Z]]
272273 ;
280281
281282 define float @test12_reassoc(float %X) {
282283 ; CHECK-LABEL: @test12_reassoc(
283 ; CHECK-NEXT: [[A:%.*]] = fsub reassoc float 1.000000e+00, %X
284 ; CHECK-NEXT: [[B:%.*]] = fsub reassoc float 2.000000e+00, %X
285 ; CHECK-NEXT: [[C:%.*]] = fsub reassoc float 3.000000e+00, %X
284 ; CHECK-NEXT: [[A:%.*]] = fsub reassoc float 1.000000e+00, [[X:%.*]]
285 ; CHECK-NEXT: [[B:%.*]] = fsub reassoc float 2.000000e+00, [[X]]
286 ; CHECK-NEXT: [[C:%.*]] = fsub reassoc float 3.000000e+00, [[X]]
286287 ; CHECK-NEXT: [[Y:%.*]] = fadd reassoc float [[A]], [[B]]
287288 ; CHECK-NEXT: [[Z:%.*]] = fadd reassoc float [[C]], [[Y]]
288289 ; CHECK-NEXT: ret float [[Z]]
297298
298299 define float @test13(float %X1, float %X2, float %X3) {
299300 ; CHECK-LABEL: @test13(
300 ; CHECK-NEXT: [[REASS_ADD:%.*]] = fsub fast float %X3, %X2
301 ; CHECK-NEXT: [[REASS_MUL:%.*]] = fmul fast float [[REASS_ADD]], %X1
301 ; CHECK-NEXT: [[REASS_ADD:%.*]] = fsub fast float [[X3:%.*]], [[X2:%.*]]
302 ; CHECK-NEXT: [[REASS_MUL:%.*]] = fmul fast float [[REASS_ADD]], [[X1:%.*]]
302303 ; CHECK-NEXT: ret float [[REASS_MUL]]
303304 ;
304305 %A = fsub fast float 0.000000e+00, %X1
310311
311312 define float @test13_reassoc(float %X1, float %X2, float %X3) {
312313 ; CHECK-LABEL: @test13_reassoc(
313 ; CHECK-NEXT: [[A:%.*]] = fsub reassoc float 0.000000e+00, %X1
314 ; CHECK-NEXT: [[B:%.*]] = fmul reassoc float [[A]], %X2
315 ; CHECK-NEXT: [[C:%.*]] = fmul reassoc float %X1, %X3
314 ; CHECK-NEXT: [[A:%.*]] = fsub reassoc float 0.000000e+00, [[X1:%.*]]
315 ; CHECK-NEXT: [[B:%.*]] = fmul reassoc float [[A]], [[X2:%.*]]
316 ; CHECK-NEXT: [[C:%.*]] = fmul reassoc float [[X1]], [[X3:%.*]]
316317 ; CHECK-NEXT: [[D:%.*]] = fadd reassoc float [[B]], [[C]]
317318 ; CHECK-NEXT: ret float [[D]]
318319 ;
325326
326327 define float @test14(float %X1, float %X2) {
327328 ; CHECK-LABEL: @test14(
328 ; CHECK-NEXT: [[TMP1:%.*]] = fsub fast float %X1, %X2
329 ; CHECK-NEXT: [[TMP1:%.*]] = fsub fast float [[X1:%.*]], [[X2:%.*]]
329330 ; CHECK-NEXT: [[TMP2:%.*]] = fmul fast float [[TMP1]], 4.700000e+01
330331 ; CHECK-NEXT: ret float [[TMP2]]
331332 ;
337338
338339 define float @test14_reassoc(float %X1, float %X2) {
339340 ; CHECK-LABEL: @test14_reassoc(
340 ; CHECK-NEXT: [[B:%.*]] = fmul reassoc float %X1, 4.700000e+01
341 ; CHECK-NEXT: [[C:%.*]] = fmul reassoc float %X2, 4.700000e+01
341 ; CHECK-NEXT: [[B:%.*]] = fmul reassoc float [[X1:%.*]], 4.700000e+01
342 ; CHECK-NEXT: [[C:%.*]] = fmul reassoc float [[X2:%.*]], 4.700000e+01
342343 ; CHECK-NEXT: [[D1:%.*]] = fsub reassoc float [[B]], [[C]]
343344 ; CHECK-NEXT: ret float [[D1]]
344345 ;
350351
351352 define float @test15(float %arg) {
352353 ; CHECK-LABEL: @test15(
353 ; CHECK-NEXT: [[T2:%.*]] = fmul fast float %arg, 1.440000e+02
354 ; CHECK-NEXT: [[T2:%.*]] = fmul fast float [[ARG:%.*]], 1.440000e+02
354355 ; CHECK-NEXT: ret float [[T2]]
355356 ;
356357 %t1 = fmul fast float 1.200000e+01, %arg
360361
361362 define float @test15_reassoc(float %arg) {
362363 ; CHECK-LABEL: @test15_reassoc(
363 ; CHECK-NEXT: [[T1:%.*]] = fmul reassoc float %arg, 1.200000e+01
364 ; CHECK-NEXT: [[T1:%.*]] = fmul reassoc float [[ARG:%.*]], 1.200000e+01
364365 ; CHECK-NEXT: [[T2:%.*]] = fmul reassoc float [[T1]], 1.200000e+01
365366 ; CHECK-NEXT: ret float [[T2]]
366367 ;
372373 ; (b+(a+1234))+-a -> b+1234
373374 define float @test16(float %b, float %a) {
374375 ; CHECK-LABEL: @test16(
375 ; CHECK-NEXT: [[TMP1:%.*]] = fadd fast float %b, 1.234000e+03
376 ; CHECK-NEXT: [[TMP1:%.*]] = fadd fast float [[B:%.*]], 1.234000e+03
376377 ; CHECK-NEXT: ret float [[TMP1]]
377378 ;
378379 %1 = fadd fast float %a, 1234.0
384385
385386 define float @test16_reassoc(float %b, float %a) {
386387 ; CHECK-LABEL: @test16_reassoc(
387 ; CHECK-NEXT: [[TMP1:%.*]] = fadd reassoc float %a, 1.234000e+03
388 ; CHECK-NEXT: [[TMP2:%.*]] = fadd reassoc float [[TMP1]], %b
389 ; CHECK-NEXT: [[TMP3:%.*]] = fsub reassoc float 0.000000e+00, %a
388 ; CHECK-NEXT: [[TMP1:%.*]] = fadd reassoc float [[A:%.*]], 1.234000e+03
389 ; CHECK-NEXT: [[TMP2:%.*]] = fadd reassoc float [[TMP1]], [[B:%.*]]
390 ; CHECK-NEXT: [[TMP3:%.*]] = fsub reassoc float 0.000000e+00, [[A]]
390391 ; CHECK-NEXT: [[TMP4:%.*]] = fadd reassoc float [[TMP3]], [[TMP2]]
391392 ; CHECK-NEXT: ret float [[TMP4]]
392393 ;
401402
402403 define float @test17(float %a, float %b, float %z) {
403404 ; CHECK-LABEL: @test17(
404 ; CHECK-NEXT: [[E:%.*]] = fmul fast float %a, 1.234500e+04
405 ; CHECK-NEXT: [[F:%.*]] = fmul fast float [[E]], %b
406 ; CHECK-NEXT: [[G:%.*]] = fmul fast float [[F]], %z
405 ; CHECK-NEXT: [[E:%.*]] = fmul fast float [[A:%.*]], 1.234500e+04
406 ; CHECK-NEXT: [[F:%.*]] = fmul fast float [[E]], [[B:%.*]]
407 ; CHECK-NEXT: [[G:%.*]] = fmul fast float [[F]], [[Z:%.*]]
407408 ; CHECK-NEXT: ret float [[G]]
408409 ;
409410 %c = fsub fast float 0.000000e+00, %z
416417
417418 define float @test17_reassoc(float %a, float %b, float %z) {
418419 ; CHECK-LABEL: @test17_reassoc(
419 ; CHECK-NEXT: [[C:%.*]] = fsub reassoc float 0.000000e+00, %z
420 ; CHECK-NEXT: [[D:%.*]] = fmul reassoc float %a, %b
420 ; CHECK-NEXT: [[C:%.*]] = fsub reassoc float 0.000000e+00, [[Z:%.*]]
421 ; CHECK-NEXT: [[D:%.*]] = fmul reassoc float [[A:%.*]], [[B:%.*]]
421422 ; CHECK-NEXT: [[E:%.*]] = fmul reassoc float [[D]], [[C]]
422423 ; CHECK-NEXT: [[F:%.*]] = fmul reassoc float [[E]], 1.234500e+04
423424 ; CHECK-NEXT: [[G:%.*]] = fsub reassoc float 0.000000e+00, [[F]]
433434
434435 define float @test18(float %a, float %b, float %z) {
435436 ; CHECK-LABEL: @test18(
436 ; CHECK-NEXT: [[E:%.*]] = fmul fast float %a, 4.000000e+01
437 ; CHECK-NEXT: [[F:%.*]] = fmul fast float [[E]], %z
437 ; CHECK-NEXT: [[E:%.*]] = fmul fast float [[A:%.*]], 4.000000e+01
438 ; CHECK-NEXT: [[F:%.*]] = fmul fast float [[E]], [[Z:%.*]]
438439 ; CHECK-NEXT: ret float [[F]]
439440 ;
440441 %d = fmul fast float %z, 4.000000e+01
446447
447448 define float @test18_reassoc(float %a, float %b, float %z) {
448449 ; CHECK-LABEL: @test18_reassoc(
449 ; CHECK-NEXT: [[D:%.*]] = fmul reassoc float %z, 4.000000e+01
450 ; CHECK-NEXT: [[D:%.*]] = fmul reassoc float [[Z:%.*]], 4.000000e+01
450451 ; CHECK-NEXT: [[C:%.*]] = fsub reassoc float 0.000000e+00, [[D]]
451 ; CHECK-NEXT: [[E:%.*]] = fmul reassoc float [[C]], %a
452 ; CHECK-NEXT: [[E:%.*]] = fmul reassoc float [[C]], [[A:%.*]]
452453 ; CHECK-NEXT: [[F:%.*]] = fsub reassoc float 0.000000e+00, [[E]]
453454 ; CHECK-NEXT: ret float [[F]]
454455 ;
462463 ; With sub reassociation, constant folding can eliminate the 12 and -12 constants.
463464 define float @test19(float %A, float %B) {
464465 ; CHECK-LABEL: @test19(
465 ; CHECK-NEXT: [[Z:%.*]] = fsub fast float %A, %B
466 ; CHECK-NEXT: [[Z:%.*]] = fsub fast float [[A:%.*]], [[B:%.*]]
466467 ; CHECK-NEXT: ret float [[Z]]
467468 ;
468469 %X = fadd fast float -1.200000e+01, %A
473474
474475 define float @test19_reassoc(float %A, float %B) {
475476 ; CHECK-LABEL: @test19_reassoc(
476 ; CHECK-NEXT: [[X:%.*]] = fadd reassoc float %A, -1.200000e+01
477 ; CHECK-NEXT: [[Y:%.*]] = fsub reassoc float [[X]], %B
477 ; CHECK-NEXT: [[X:%.*]] = fadd reassoc float [[A:%.*]], -1.200000e+01
478 ; CHECK-NEXT: [[Y:%.*]] = fsub reassoc float [[X]], [[B:%.*]]
478479 ; CHECK-NEXT: [[Z:%.*]] = fadd reassoc float [[Y]], 1.200000e+01
479480 ; CHECK-NEXT: ret float [[Z]]
480481 ;
491492 ; %sum = fadd fast float %c, %b
492493 ; %t7 = fsub fast float 0, %sum
493494 ; CHECK-LABEL: @test20(
494 ; CHECK-NEXT: [[B_NEG:%.*]] = fsub fast float -0.000000e+00, %b
495 ; CHECK-NEXT: [[T7:%.*]] = fsub fast float [[B_NEG]], %c
495 ; CHECK-NEXT: [[B_NEG:%.*]] = fsub fast float -0.000000e+00, [[B:%.*]]
496 ; CHECK-NEXT: [[T7:%.*]] = fsub fast float [[B_NEG]], [[C:%.*]]
496497 ; CHECK-NEXT: ret float [[T7]]
497498 ;
498499 %t3 = fsub fast float %a, %b
503504
504505 define float @test20_reassoc(float %a, float %b, float %c) nounwind {
505506 ; CHECK-LABEL: @test20_reassoc(
506 ; CHECK-NEXT: [[T3:%.*]] = fsub reassoc float %a, %b
507 ; CHECK-NEXT: [[T5:%.*]] = fsub reassoc float [[T3]], %c
508 ; CHECK-NEXT: [[T7:%.*]] = fsub reassoc float [[T5]], %a
507 ; CHECK-NEXT: [[T3:%.*]] = fsub reassoc float [[A:%.*]], [[B:%.*]]
508 ; CHECK-NEXT: [[T5:%.*]] = fsub reassoc float [[T3]], [[C:%.*]]
509 ; CHECK-NEXT: [[T7:%.*]] = fsub reassoc float [[T5]], [[A]]
509510 ; CHECK-NEXT: ret float [[T7]]
510511 ;
511512 %t3 = fsub reassoc float %a, %b