Commit daf0182
authored
[ConstraintElim] Apply add with neg constant first during decomp. (llvm#164791)
We have dedicated decomposition logic for (add %x, -C), but if we have
(add nsw %x, -C) we will first apply the generic logic for NSWAdd, which
gives worse results for negative constants in practice.
Update the code to first apply the pattern with negative constants.
Helps to remove a number of runtime checks in practice:
dtcxzyw/llvm-opt-benchmark#2968
Alive2 proofs for the test changes: https://alive2.llvm.org/ce/z/JfR2Ma
PR: llvm#1647911 parent 11bbee9 commit daf0182
File tree
3 files changed
+14
-18
lines changed- llvm
- lib/Transforms/Scalar
- test/Transforms/ConstraintElimination
3 files changed
+14
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
614 | 614 | | |
615 | 615 | | |
616 | 616 | | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
617 | 627 | | |
618 | 628 | | |
619 | 629 | | |
| |||
627 | 637 | | |
628 | 638 | | |
629 | 639 | | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | 640 | | |
641 | 641 | | |
642 | 642 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
757 | 757 | | |
758 | 758 | | |
759 | 759 | | |
760 | | - | |
761 | | - | |
| 760 | + | |
762 | 761 | | |
763 | 762 | | |
764 | 763 | | |
| |||
823 | 822 | | |
824 | 823 | | |
825 | 824 | | |
826 | | - | |
827 | | - | |
| 825 | + | |
828 | 826 | | |
829 | 827 | | |
830 | 828 | | |
| |||
Lines changed: 2 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
389 | 389 | | |
390 | 390 | | |
391 | 391 | | |
392 | | - | |
393 | | - | |
| 392 | + | |
394 | 393 | | |
395 | 394 | | |
396 | 395 | | |
| |||
415 | 414 | | |
416 | 415 | | |
417 | 416 | | |
418 | | - | |
419 | | - | |
| 417 | + | |
420 | 418 | | |
421 | 419 | | |
422 | 420 | | |
| |||
0 commit comments