Commit adfd59f
committed
[InstCombine] Introduce
Match icmps of binops where both operands are select with constant arms,
i.e., `icmp pred (select A ? C1 : C2) binop (select B ? C3 : C4), C5`.
Fold such patterns by creating a truth table of the possible four
constant variants, and materialize back the optimal logic from it via
`createLogicFromTable` helper. This also generalizes an existing fold,
which has therefore been dropped.
Proofs: https://alive2.llvm.org/ce/z/NS7Vzu.
Fixes: llvm#138212.foldICmpBinOpWithConstantViaTruthTable folding1 parent 1bfd94b commit adfd59f
File tree
4 files changed
+66
-83
lines changed- llvm
- lib/Transforms/InstCombine
- test/Transforms/InstCombine
4 files changed
+66
-83
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1966 | 1966 | | |
1967 | 1967 | | |
1968 | 1968 | | |
1969 | | - | |
1970 | | - | |
1971 | | - | |
1972 | | - | |
1973 | | - | |
1974 | | - | |
1975 | | - | |
1976 | | - | |
1977 | | - | |
1978 | | - | |
1979 | | - | |
1980 | | - | |
1981 | | - | |
1982 | | - | |
1983 | | - | |
1984 | | - | |
1985 | | - | |
1986 | | - | |
1987 | | - | |
1988 | | - | |
1989 | | - | |
1990 | | - | |
1991 | | - | |
1992 | | - | |
1993 | 1969 | | |
1994 | 1970 | | |
1995 | 1971 | | |
| |||
3110 | 3086 | | |
3111 | 3087 | | |
3112 | 3088 | | |
| 3089 | + | |
| 3090 | + | |
| 3091 | + | |
| 3092 | + | |
| 3093 | + | |
| 3094 | + | |
| 3095 | + | |
| 3096 | + | |
| 3097 | + | |
| 3098 | + | |
| 3099 | + | |
| 3100 | + | |
| 3101 | + | |
| 3102 | + | |
| 3103 | + | |
| 3104 | + | |
| 3105 | + | |
| 3106 | + | |
| 3107 | + | |
| 3108 | + | |
| 3109 | + | |
| 3110 | + | |
| 3111 | + | |
| 3112 | + | |
| 3113 | + | |
| 3114 | + | |
| 3115 | + | |
| 3116 | + | |
| 3117 | + | |
| 3118 | + | |
| 3119 | + | |
| 3120 | + | |
| 3121 | + | |
| 3122 | + | |
| 3123 | + | |
| 3124 | + | |
| 3125 | + | |
| 3126 | + | |
3113 | 3127 | | |
3114 | 3128 | | |
3115 | 3129 | | |
| |||
4014 | 4028 | | |
4015 | 4029 | | |
4016 | 4030 | | |
4017 | | - | |
| 4031 | + | |
| 4032 | + | |
| 4033 | + | |
| 4034 | + | |
| 4035 | + | |
| 4036 | + | |
| 4037 | + | |
4018 | 4038 | | |
4019 | 4039 | | |
4020 | 4040 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
736 | 736 | | |
737 | 737 | | |
738 | 738 | | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
739 | 742 | | |
740 | 743 | | |
741 | 744 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
362 | 362 | | |
363 | 363 | | |
364 | 364 | | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
| 365 | + | |
369 | 366 | | |
370 | 367 | | |
371 | 368 | | |
| |||
377 | 374 | | |
378 | 375 | | |
379 | 376 | | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
| 377 | + | |
| 378 | + | |
384 | 379 | | |
385 | 380 | | |
386 | 381 | | |
| |||
392 | 387 | | |
393 | 388 | | |
394 | 389 | | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
| 390 | + | |
400 | 391 | | |
401 | 392 | | |
402 | 393 | | |
| |||
411 | 402 | | |
412 | 403 | | |
413 | 404 | | |
414 | | - | |
| 405 | + | |
415 | 406 | | |
416 | 407 | | |
417 | 408 | | |
| |||
424 | 415 | | |
425 | 416 | | |
426 | 417 | | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
| 418 | + | |
431 | 419 | | |
432 | 420 | | |
433 | 421 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
| 331 | + | |
335 | 332 | | |
336 | 333 | | |
337 | 334 | | |
| |||
345 | 342 | | |
346 | 343 | | |
347 | 344 | | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
| 345 | + | |
352 | 346 | | |
353 | 347 | | |
354 | 348 | | |
| |||
387 | 381 | | |
388 | 382 | | |
389 | 383 | | |
390 | | - | |
391 | | - | |
392 | 384 | | |
393 | 385 | | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
| 386 | + | |
398 | 387 | | |
399 | 388 | | |
400 | 389 | | |
| |||
404 | 393 | | |
405 | 394 | | |
406 | 395 | | |
407 | | - | |
408 | | - | |
409 | 396 | | |
410 | 397 | | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
| 398 | + | |
| 399 | + | |
415 | 400 | | |
416 | 401 | | |
417 | 402 | | |
| |||
512 | 497 | | |
513 | 498 | | |
514 | 499 | | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
| 500 | + | |
| 501 | + | |
519 | 502 | | |
520 | 503 | | |
521 | 504 | | |
| |||
529 | 512 | | |
530 | 513 | | |
531 | 514 | | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
| 515 | + | |
| 516 | + | |
536 | 517 | | |
537 | 518 | | |
538 | 519 | | |
| |||
571 | 552 | | |
572 | 553 | | |
573 | 554 | | |
574 | | - | |
575 | | - | |
576 | 555 | | |
577 | 556 | | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
| 557 | + | |
| 558 | + | |
582 | 559 | | |
583 | 560 | | |
584 | 561 | | |
| |||
588 | 565 | | |
589 | 566 | | |
590 | 567 | | |
591 | | - | |
592 | | - | |
593 | 568 | | |
594 | 569 | | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | | - | |
| 570 | + | |
599 | 571 | | |
600 | 572 | | |
601 | 573 | | |
| |||
0 commit comments