Commit a783763
[SCEV] Handle more adds in computeConstantDifference() (#101339)
Currently it only deals with the case where we're subtracting adds with
at most one non-constant operand. This patch extends it to cancel out
common operands for the subtraction of arbitrary add expressions.
The background here is that I want to replace a getMinusSCEV() call in
LAA with computeConstantDifference():
https://github.com/llvm/llvm-project/blob/93fecc2577ece0329f3bbe2719bbc5b4b9b30010/llvm/lib/Analysis/LoopAccessAnalysis.cpp#L1602-L1603
This particular call is very expensive in some cases (e.g. lencod with
LTO) and computeConstantDifference() could achieve this much more
cheaply, because it does not need to construct new SCEV expressions.
However, the current computeConstantDifference() implementation is too
weak for this and misses many basic cases. This is a step towards making
it more powerful while still keeping it pretty fast.1 parent 605aa52 commit a783763
File tree
2 files changed
+32
-27
lines changed- llvm
- lib/Analysis
- unittests/Analysis
2 files changed
+32
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11947 | 11947 | | |
11948 | 11948 | | |
11949 | 11949 | | |
| 11950 | + | |
11950 | 11951 | | |
11951 | | - | |
| 11952 | + | |
11952 | 11953 | | |
11953 | 11954 | | |
11954 | 11955 | | |
| |||
11971 | 11972 | | |
11972 | 11973 | | |
11973 | 11974 | | |
11974 | | - | |
11975 | | - | |
11976 | | - | |
11977 | | - | |
11978 | | - | |
11979 | | - | |
11980 | | - | |
11981 | | - | |
11982 | | - | |
11983 | | - | |
11984 | | - | |
11985 | | - | |
11986 | | - | |
11987 | | - | |
11988 | | - | |
11989 | | - | |
11990 | | - | |
11991 | | - | |
11992 | | - | |
11993 | | - | |
11994 | | - | |
| 11975 | + | |
| 11976 | + | |
| 11977 | + | |
| 11978 | + | |
| 11979 | + | |
| 11980 | + | |
| 11981 | + | |
| 11982 | + | |
| 11983 | + | |
| 11984 | + | |
| 11985 | + | |
| 11986 | + | |
| 11987 | + | |
| 11988 | + | |
| 11989 | + | |
| 11990 | + | |
| 11991 | + | |
| 11992 | + | |
11995 | 11993 | | |
11996 | | - | |
11997 | | - | |
11998 | | - | |
| 11994 | + | |
| 11995 | + | |
| 11996 | + | |
| 11997 | + | |
11999 | 11998 | | |
12000 | | - | |
| 11999 | + | |
12001 | 12000 | | |
12002 | 12001 | | |
12003 | 12002 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1117 | 1117 | | |
1118 | 1118 | | |
1119 | 1119 | | |
1120 | | - | |
| 1120 | + | |
1121 | 1121 | | |
1122 | 1122 | | |
1123 | 1123 | | |
| 1124 | + | |
| 1125 | + | |
1124 | 1126 | | |
1125 | 1127 | | |
1126 | 1128 | | |
| |||
1141 | 1143 | | |
1142 | 1144 | | |
1143 | 1145 | | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
1144 | 1149 | | |
1145 | 1150 | | |
1146 | 1151 | | |
| |||
1162 | 1167 | | |
1163 | 1168 | | |
1164 | 1169 | | |
| 1170 | + | |
1165 | 1171 | | |
1166 | 1172 | | |
1167 | 1173 | | |
| |||
0 commit comments