Commit 99addbf
authored
[LV] Vectorize selecting last IV of min/max element. (#141431)
Add support for vectorizing loops that select the index of the minimum
or maximum element. The patch implements vectorizing those patterns by
combining Min/Max and FindFirstIV reductions.
It extends matching Min/Max reductions to allow in-loop users that are
FindLastIV reductions. It records a flag indicating that the Min/Max
reduction is used by another reduction. The extra user is then check as
part of the new `handleMultiUseReductions` VPlan transformation.
It processes any reduction that has other reduction users. The reduction
using the min/max reduction currently must be a FindLastIV reduction,
which needs adjusting to compute the correct result:
1. We need to find the last IV for which the condition based on the
min/max reduction is true,
2. Compare the partial min/max reduction result to its final value and,
3. Select the lanes of the partial FindLastIV reductions which
correspond to the lanes matching the min/max reduction result.
Depends on #140451
PR: #1414311 parent e99d8ad commit 99addbf
File tree
15 files changed
+1283
-134
lines changed- llvm
- include/llvm/Analysis
- lib
- Analysis
- Transforms
- Utils
- Vectorize
- test/Transforms/LoopVectorize
- AArch64
15 files changed
+1283
-134
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
| 99 | + | |
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| 103 | + | |
102 | 104 | | |
103 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
104 | 109 | | |
105 | 110 | | |
106 | 111 | | |
| |||
339 | 344 | | |
340 | 345 | | |
341 | 346 | | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
342 | 354 | | |
343 | 355 | | |
344 | 356 | | |
| |||
376 | 388 | | |
377 | 389 | | |
378 | 390 | | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
379 | 395 | | |
380 | 396 | | |
381 | 397 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
219 | 265 | | |
220 | 266 | | |
221 | 267 | | |
| |||
227 | 273 | | |
228 | 274 | | |
229 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
230 | 281 | | |
231 | 282 | | |
232 | 283 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1254 | 1254 | | |
1255 | 1255 | | |
1256 | 1256 | | |
| 1257 | + | |
| 1258 | + | |
1257 | 1259 | | |
1258 | 1260 | | |
1259 | 1261 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
877 | 877 | | |
878 | 878 | | |
879 | 879 | | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
880 | 885 | | |
881 | 886 | | |
882 | 887 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6593 | 6593 | | |
6594 | 6594 | | |
6595 | 6595 | | |
| 6596 | + | |
| 6597 | + | |
| 6598 | + | |
| 6599 | + | |
| 6600 | + | |
6596 | 6601 | | |
6597 | 6602 | | |
6598 | 6603 | | |
| |||
7998 | 8003 | | |
7999 | 8004 | | |
8000 | 8005 | | |
8001 | | - | |
8002 | | - | |
8003 | | - | |
| 8006 | + | |
| 8007 | + | |
| 8008 | + | |
| 8009 | + | |
8004 | 8010 | | |
8005 | 8011 | | |
8006 | 8012 | | |
| |||
8221 | 8227 | | |
8222 | 8228 | | |
8223 | 8229 | | |
8224 | | - | |
| 8230 | + | |
| 8231 | + | |
8225 | 8232 | | |
8226 | 8233 | | |
8227 | 8234 | | |
| |||
8555 | 8562 | | |
8556 | 8563 | | |
8557 | 8564 | | |
| 8565 | + | |
| 8566 | + | |
| 8567 | + | |
| 8568 | + | |
| 8569 | + | |
8558 | 8570 | | |
8559 | 8571 | | |
8560 | 8572 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2071 | 2071 | | |
2072 | 2072 | | |
2073 | 2073 | | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
2074 | 2077 | | |
2075 | 2078 | | |
2076 | 2079 | | |
| |||
2136 | 2139 | | |
2137 | 2140 | | |
2138 | 2141 | | |
2139 | | - | |
| 2142 | + | |
2140 | 2143 | | |
2141 | 2144 | | |
2142 | 2145 | | |
| |||
2432 | 2435 | | |
2433 | 2436 | | |
2434 | 2437 | | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
2435 | 2444 | | |
2436 | 2445 | | |
2437 | 2446 | | |
2438 | | - | |
| 2447 | + | |
| 2448 | + | |
2439 | 2449 | | |
2440 | | - | |
| 2450 | + | |
| 2451 | + | |
2441 | 2452 | | |
2442 | 2453 | | |
2443 | 2454 | | |
2444 | 2455 | | |
2445 | 2456 | | |
2446 | 2457 | | |
2447 | | - | |
| 2458 | + | |
2448 | 2459 | | |
2449 | 2460 | | |
2450 | 2461 | | |
| |||
2481 | 2492 | | |
2482 | 2493 | | |
2483 | 2494 | | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
| 2498 | + | |
| 2499 | + | |
2484 | 2500 | | |
2485 | 2501 | | |
2486 | 2502 | | |
| |||
0 commit comments