Commit 90e5063
[IR] Handle trunc for ptrtoaddr(inttoptr) cast pair (llvm#162842)
For ptrtoint(inttoptr) and ptrtoaddr(inttoptr), handle the case where
the source and destination size do not match and convert to either zext
or trunc. We can't do this if the middle size is smaller than both
src/dest, because we'd have to perform an additional masking operation
in that case.
Most of these cases are handled by dint of ptrtoint/inttoptr size
canonicalization (so I added some unit tests instead). However, the
ptrtoaddr(inttoptr) case where the pointer size and address size differ
is relevant, as in that case the mismatch in integer sizes is canonical.1 parent 64e5c51 commit 90e5063
File tree
3 files changed
+50
-11
lines changed- llvm
- lib/IR
- test/Transforms/InstCombine
- unittests/IR
3 files changed
+50
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2965 | 2965 | | |
2966 | 2966 | | |
2967 | 2967 | | |
2968 | | - | |
2969 | | - | |
| 2968 | + | |
2970 | 2969 | | |
2971 | 2970 | | |
2972 | 2971 | | |
2973 | 2972 | | |
2974 | 2973 | | |
2975 | 2974 | | |
2976 | 2975 | | |
2977 | | - | |
2978 | | - | |
2979 | | - | |
2980 | | - | |
| 2976 | + | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
| 2980 | + | |
| 2981 | + | |
| 2982 | + | |
| 2983 | + | |
| 2984 | + | |
2981 | 2985 | | |
2982 | 2986 | | |
2983 | 2987 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
| 26 | + | |
30 | 27 | | |
31 | 28 | | |
32 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
606 | 606 | | |
607 | 607 | | |
608 | 608 | | |
609 | | - | |
| 609 | + | |
610 | 610 | | |
611 | 611 | | |
| 612 | + | |
612 | 613 | | |
613 | 614 | | |
614 | 615 | | |
| 616 | + | |
615 | 617 | | |
616 | 618 | | |
617 | 619 | | |
| |||
637 | 639 | | |
638 | 640 | | |
639 | 641 | | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
640 | 678 | | |
641 | 679 | | |
642 | 680 | | |
| |||
0 commit comments