Commit 4e692c9
committed
[LoopIdiom] Don't transform loop into memmove when load from body has more than one use
This change fixes issue found by Markus: https://reviews.llvm.org/rG11338e998df1
Before this patch following code was transformed to memmove:
for (int i = 15; i >= 1; i--) {
p[i] = p[i-1];
sum += p[i-1];
}
However load from p[i-1] is used not only by store to p[i] but also by sum computation.
Therefore we cannot emit memmove in loop header.
Differential Revision: https://reviews.llvm.org/D107964
(cherry picked from commit bdcf042)1 parent c22eb9a commit 4e692c9
File tree
2 files changed
+7
-5
lines changed- llvm
- lib/Transforms/Scalar
- test/Transforms/LoopIdiom
2 files changed
+7
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1247 | 1247 | | |
1248 | 1248 | | |
1249 | 1249 | | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
1250 | 1255 | | |
1251 | 1256 | | |
1252 | 1257 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1300 | 1300 | | |
1301 | 1301 | | |
1302 | 1302 | | |
1303 | | - | |
| 1303 | + | |
1304 | 1304 | | |
1305 | 1305 | | |
1306 | 1306 | | |
1307 | | - | |
1308 | | - | |
1309 | | - | |
1310 | | - | |
1311 | 1307 | | |
1312 | 1308 | | |
1313 | 1309 | | |
| |||
1321 | 1317 | | |
1322 | 1318 | | |
1323 | 1319 | | |
| 1320 | + | |
1324 | 1321 | | |
1325 | 1322 | | |
1326 | 1323 | | |
| |||
0 commit comments