Commit 9fee32d
committed
[InstSimplify] Extend icmp-of-add simplification to sle/sgt/sge
When comparing additions with the same base where one has `nsw`, the
following simplification can be performed:
```llvm
icmp slt/sgt/sle/sge (x + C1), (x +nsw C2)
=>
icmp slt/sgt/sle/sge C1, C2
```
Previously this was only done for `slt`. This patch extends it to the
`sgt`, `sle`, and `sge` predicates when either of the conditions hold:
- `C1 <= C2 && C1 >= 0`, or
- `C2 <= C1 && C1 <= 0`
This patch also handles the `C1 == C2` case, which was previously excluded.
Proof: https://alive2.llvm.org/ce/z/LtmY4f1 parent c9a2887 commit 9fee32d
File tree
2 files changed
+18
-40
lines changed- llvm
- lib/Analysis
- test/Transforms/InstSimplify
2 files changed
+18
-40
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3261 | 3261 | | |
3262 | 3262 | | |
3263 | 3263 | | |
3264 | | - | |
| 3264 | + | |
3265 | 3265 | | |
3266 | 3266 | | |
3267 | 3267 | | |
3268 | | - | |
| 3268 | + | |
3269 | 3269 | | |
3270 | 3270 | | |
3271 | | - | |
3272 | | - | |
| 3271 | + | |
| 3272 | + | |
3273 | 3273 | | |
3274 | 3274 | | |
3275 | 3275 | | |
3276 | | - | |
3277 | | - | |
| 3276 | + | |
| 3277 | + | |
| 3278 | + | |
| 3279 | + | |
3278 | 3280 | | |
3279 | 3281 | | |
3280 | 3282 | | |
| |||
3289 | 3291 | | |
3290 | 3292 | | |
3291 | 3293 | | |
3292 | | - | |
3293 | | - | |
| 3294 | + | |
| 3295 | + | |
3294 | 3296 | | |
3295 | 3297 | | |
3296 | 3298 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2687 | 2687 | | |
2688 | 2688 | | |
2689 | 2689 | | |
2690 | | - | |
2691 | | - | |
2692 | | - | |
2693 | | - | |
| 2690 | + | |
2694 | 2691 | | |
2695 | 2692 | | |
2696 | 2693 | | |
| |||
2805 | 2802 | | |
2806 | 2803 | | |
2807 | 2804 | | |
2808 | | - | |
2809 | | - | |
2810 | | - | |
2811 | | - | |
| 2805 | + | |
2812 | 2806 | | |
2813 | 2807 | | |
2814 | 2808 | | |
| |||
2883 | 2877 | | |
2884 | 2878 | | |
2885 | 2879 | | |
2886 | | - | |
2887 | | - | |
2888 | | - | |
2889 | | - | |
| 2880 | + | |
2890 | 2881 | | |
2891 | 2882 | | |
2892 | 2883 | | |
| |||
2919 | 2910 | | |
2920 | 2911 | | |
2921 | 2912 | | |
2922 | | - | |
2923 | | - | |
2924 | | - | |
2925 | | - | |
| 2913 | + | |
2926 | 2914 | | |
2927 | 2915 | | |
2928 | 2916 | | |
| |||
2932 | 2920 | | |
2933 | 2921 | | |
2934 | 2922 | | |
2935 | | - | |
2936 | | - | |
2937 | | - | |
2938 | | - | |
| 2923 | + | |
2939 | 2924 | | |
2940 | 2925 | | |
2941 | 2926 | | |
| |||
2967 | 2952 | | |
2968 | 2953 | | |
2969 | 2954 | | |
2970 | | - | |
2971 | | - | |
2972 | | - | |
2973 | | - | |
| 2955 | + | |
2974 | 2956 | | |
2975 | 2957 | | |
2976 | 2958 | | |
| |||
2980 | 2962 | | |
2981 | 2963 | | |
2982 | 2964 | | |
2983 | | - | |
2984 | | - | |
2985 | | - | |
2986 | | - | |
| 2965 | + | |
2987 | 2966 | | |
2988 | 2967 | | |
2989 | 2968 | | |
| |||
2993 | 2972 | | |
2994 | 2973 | | |
2995 | 2974 | | |
2996 | | - | |
2997 | | - | |
2998 | | - | |
2999 | | - | |
| 2975 | + | |
3000 | 2976 | | |
3001 | 2977 | | |
3002 | 2978 | | |
| |||
0 commit comments