Commit cfbd563
[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 e8d8800 commit cfbd563
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 | |
|---|---|---|---|
| |||
7536 | 7536 | | |
7537 | 7537 | | |
7538 | 7538 | | |
7539 | | - | |
| 7539 | + | |
7540 | 7540 | | |
7541 | 7541 | | |
7542 | 7542 | | |
7543 | 7543 | | |
7544 | | - | |
7545 | | - | |
7546 | | - | |
| 7544 | + | |
| 7545 | + | |
| 7546 | + | |
| 7547 | + | |
| 7548 | + | |
| 7549 | + | |
7547 | 7550 | | |
7548 | 7551 | | |
7549 | 7552 | | |
| |||
10125 | 10128 | | |
10126 | 10129 | | |
10127 | 10130 | | |
| 10131 | + | |
| 10132 | + | |
| 10133 | + | |
| 10134 | + | |
| 10135 | + | |
| 10136 | + | |
| 10137 | + | |
| 10138 | + | |
| 10139 | + | |
| 10140 | + | |
| 10141 | + | |
| 10142 | + | |
| 10143 | + | |
| 10144 | + | |
| 10145 | + | |
| 10146 | + | |
| 10147 | + | |
| 10148 | + | |
| 10149 | + | |
| 10150 | + | |
| 10151 | + | |
| 10152 | + | |
| 10153 | + | |
| 10154 | + | |
| 10155 | + | |
| 10156 | + | |
| 10157 | + | |
| 10158 | + | |
| 10159 | + | |
| 10160 | + | |
10128 | 10161 | | |
10129 | 10162 | | |
10130 | 10163 | | |
| |||
10152 | 10185 | | |
10153 | 10186 | | |
10154 | 10187 | | |
10155 | | - | |
10156 | | - | |
10157 | | - | |
10158 | | - | |
10159 | | - | |
10160 | | - | |
10161 | | - | |
10162 | | - | |
10163 | | - | |
10164 | | - | |
10165 | | - | |
10166 | | - | |
10167 | | - | |
10168 | | - | |
10169 | | - | |
10170 | | - | |
10171 | | - | |
10172 | | - | |
| 10188 | + | |
10173 | 10189 | | |
10174 | 10190 | | |
10175 | 10191 | | |
| |||
10235 | 10251 | | |
10236 | 10252 | | |
10237 | 10253 | | |
| 10254 | + | |
| 10255 | + | |
| 10256 | + | |
| 10257 | + | |
10238 | 10258 | | |
10239 | 10259 | | |
10240 | 10260 | | |
| |||
10243 | 10263 | | |
10244 | 10264 | | |
10245 | 10265 | | |
10246 | | - | |
10247 | | - | |
| 10266 | + | |
| 10267 | + | |
10248 | 10268 | | |
10249 | 10269 | | |
10250 | 10270 | | |
| |||
10260 | 10280 | | |
10261 | 10281 | | |
10262 | 10282 | | |
| 10283 | + | |
| 10284 | + | |
| 10285 | + | |
| 10286 | + | |
| 10287 | + | |
| 10288 | + | |
| 10289 | + | |
| 10290 | + | |
| 10291 | + | |
| 10292 | + | |
| 10293 | + | |
| 10294 | + | |
| 10295 | + | |
| 10296 | + | |
| 10297 | + | |
| 10298 | + | |
| 10299 | + | |
| 10300 | + | |
| 10301 | + | |
| 10302 | + | |
| 10303 | + | |
| 10304 | + | |
| 10305 | + | |
| 10306 | + | |
| 10307 | + | |
| 10308 | + | |
| 10309 | + | |
| 10310 | + | |
| 10311 | + | |
10263 | 10312 | | |
10264 | 10313 | | |
10265 | 10314 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
406 | 406 | | |
407 | 407 | | |
408 | 408 | | |
| 409 | + | |
409 | 410 | | |
410 | 411 | | |
411 | 412 | | |
| |||
450 | 451 | | |
451 | 452 | | |
452 | 453 | | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
453 | 458 | | |
454 | 459 | | |
455 | 460 | | |
| |||
820 | 825 | | |
821 | 826 | | |
822 | 827 | | |
| 828 | + | |
823 | 829 | | |
824 | 830 | | |
825 | 831 | | |
| |||
848 | 854 | | |
849 | 855 | | |
850 | 856 | | |
| 857 | + | |
851 | 858 | | |
852 | 859 | | |
853 | 860 | | |
| |||
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 | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| 224 | + | |
224 | 225 | | |
225 | 226 | | |
226 | 227 | | |
| |||
247 | 248 | | |
248 | 249 | | |
249 | 250 | | |
250 | | - | |
| 251 | + | |
251 | 252 | | |
252 | 253 | | |
253 | 254 | | |
| |||
258 | 259 | | |
259 | 260 | | |
260 | 261 | | |
261 | | - | |
262 | | - | |
| 262 | + | |
| 263 | + | |
263 | 264 | | |
264 | 265 | | |
265 | 266 | | |
| |||
287 | 288 | | |
288 | 289 | | |
289 | 290 | | |
290 | | - | |
| 291 | + | |
291 | 292 | | |
292 | 293 | | |
293 | 294 | | |
| |||
0 commit comments