Commit 2bdc1a1
authored
[LV] Use frozen start value for FindLastIV if needed. (#132691)
FindLastIV introduces multiple uses of the start value, where in the
original source there was only a single use, when the epilogue is
vectorized.
Each use of undef may produce a different result, so introducing
multiple uses can produce incorrect results when the input is
undef/poison.
If the start value may be undef or poison, freeze it and use the frozen
value, which will be the same at all uses.
See the following scenarios in Alive2:
* Both main and epilogue vector loops execute, go to exit block: https://alive2.llvm.org/ce/z/_TSvRr
* Both main and epilogue vector loops execute, go to scalar loop: https://alive2.llvm.org/ce/z/CsPj5v
* Only epilogue vector loop executes, go to exit block: https://alive2.llvm.org/ce/z/5XqkNV
* Only epilogue vector loop executes, go to scalar loop: https://alive2.llvm.org/ce/z/JUpqRN
The latter 2 show requiring freezing the resume phi. That means we cannot freeze
in the preheader. We could move the freeze to the main iteration count check, but
that would be a bit fragile to find and other transforms can sink the freeze if needed.
Depends on #132689
and #132690.
Fixes #126836
PR: #1326911 parent d6c076e commit 2bdc1a1
File tree
4 files changed
+95
-36
lines changed- llvm
- lib/Transforms/Vectorize
- test/Transforms/LoopVectorize
- AArch64
4 files changed
+95
-36
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7659 | 7659 | | |
7660 | 7660 | | |
7661 | 7661 | | |
7662 | | - | |
| 7662 | + | |
7663 | 7663 | | |
7664 | 7664 | | |
7665 | 7665 | | |
7666 | 7666 | | |
7667 | | - | |
7668 | | - | |
7669 | | - | |
| 7667 | + | |
| 7668 | + | |
| 7669 | + | |
| 7670 | + | |
| 7671 | + | |
| 7672 | + | |
7670 | 7673 | | |
7671 | 7674 | | |
7672 | 7675 | | |
| |||
10374 | 10377 | | |
10375 | 10378 | | |
10376 | 10379 | | |
| 10380 | + | |
| 10381 | + | |
| 10382 | + | |
| 10383 | + | |
| 10384 | + | |
| 10385 | + | |
| 10386 | + | |
| 10387 | + | |
| 10388 | + | |
| 10389 | + | |
| 10390 | + | |
| 10391 | + | |
| 10392 | + | |
| 10393 | + | |
| 10394 | + | |
| 10395 | + | |
| 10396 | + | |
| 10397 | + | |
| 10398 | + | |
| 10399 | + | |
| 10400 | + | |
| 10401 | + | |
| 10402 | + | |
| 10403 | + | |
| 10404 | + | |
| 10405 | + | |
| 10406 | + | |
| 10407 | + | |
| 10408 | + | |
| 10409 | + | |
10377 | 10410 | | |
10378 | 10411 | | |
10379 | 10412 | | |
| |||
10401 | 10434 | | |
10402 | 10435 | | |
10403 | 10436 | | |
10404 | | - | |
10405 | | - | |
10406 | | - | |
10407 | | - | |
10408 | | - | |
10409 | | - | |
10410 | | - | |
10411 | | - | |
10412 | | - | |
10413 | | - | |
10414 | | - | |
10415 | | - | |
10416 | | - | |
10417 | | - | |
10418 | | - | |
10419 | | - | |
10420 | | - | |
10421 | | - | |
| 10437 | + | |
10422 | 10438 | | |
10423 | 10439 | | |
10424 | 10440 | | |
| |||
10484 | 10500 | | |
10485 | 10501 | | |
10486 | 10502 | | |
| 10503 | + | |
| 10504 | + | |
| 10505 | + | |
| 10506 | + | |
10487 | 10507 | | |
10488 | 10508 | | |
10489 | 10509 | | |
| |||
10492 | 10512 | | |
10493 | 10513 | | |
10494 | 10514 | | |
10495 | | - | |
10496 | | - | |
| 10515 | + | |
| 10516 | + | |
10497 | 10517 | | |
10498 | 10518 | | |
10499 | 10519 | | |
| |||
10509 | 10529 | | |
10510 | 10530 | | |
10511 | 10531 | | |
| 10532 | + | |
| 10533 | + | |
| 10534 | + | |
| 10535 | + | |
| 10536 | + | |
| 10537 | + | |
| 10538 | + | |
| 10539 | + | |
| 10540 | + | |
| 10541 | + | |
| 10542 | + | |
| 10543 | + | |
| 10544 | + | |
| 10545 | + | |
| 10546 | + | |
| 10547 | + | |
| 10548 | + | |
| 10549 | + | |
| 10550 | + | |
| 10551 | + | |
| 10552 | + | |
| 10553 | + | |
| 10554 | + | |
| 10555 | + | |
| 10556 | + | |
| 10557 | + | |
| 10558 | + | |
| 10559 | + | |
| 10560 | + | |
10512 | 10561 | | |
10513 | 10562 | | |
10514 | 10563 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
| 426 | + | |
426 | 427 | | |
427 | 428 | | |
428 | 429 | | |
| |||
474 | 475 | | |
475 | 476 | | |
476 | 477 | | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
477 | 482 | | |
478 | 483 | | |
479 | 484 | | |
| |||
909 | 914 | | |
910 | 915 | | |
911 | 916 | | |
| 917 | + | |
912 | 918 | | |
913 | 919 | | |
914 | 920 | | |
| |||
941 | 947 | | |
942 | 948 | | |
943 | 949 | | |
| 950 | + | |
944 | 951 | | |
945 | 952 | | |
946 | 953 | | |
| |||
Lines changed: 10 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
45 | | - | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
56 | | - | |
57 | | - | |
| 57 | + | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
85 | | - | |
| 86 | + | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
| |||
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
| 132 | + | |
131 | 133 | | |
132 | 134 | | |
133 | 135 | | |
| |||
166 | 168 | | |
167 | 169 | | |
168 | 170 | | |
169 | | - | |
| 171 | + | |
170 | 172 | | |
171 | 173 | | |
172 | 174 | | |
| |||
175 | 177 | | |
176 | 178 | | |
177 | 179 | | |
178 | | - | |
179 | | - | |
| 180 | + | |
| 181 | + | |
180 | 182 | | |
181 | 183 | | |
182 | 184 | | |
| |||
203 | 205 | | |
204 | 206 | | |
205 | 207 | | |
206 | | - | |
| 208 | + | |
207 | 209 | | |
208 | 210 | | |
209 | 211 | | |
| |||
Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
| 220 | + | |
220 | 221 | | |
221 | 222 | | |
222 | 223 | | |
| |||
243 | 244 | | |
244 | 245 | | |
245 | 246 | | |
246 | | - | |
| 247 | + | |
247 | 248 | | |
248 | 249 | | |
249 | 250 | | |
| |||
254 | 255 | | |
255 | 256 | | |
256 | 257 | | |
257 | | - | |
258 | | - | |
| 258 | + | |
| 259 | + | |
259 | 260 | | |
260 | 261 | | |
261 | 262 | | |
| |||
283 | 284 | | |
284 | 285 | | |
285 | 286 | | |
286 | | - | |
| 287 | + | |
287 | 288 | | |
288 | 289 | | |
289 | 290 | | |
| |||
0 commit comments