Commit 63e8a1b
authored
[SLP] Enable reordering for non-power-of-two vectors (llvm#106638)
This change tries to enable vector reordering during vectorization for
non-power-of-two vectors. Specifically, my goal is to be able to
vectorize reductions whose operands appear in other than identity order.
(i.e. a[1] + a[0] + a[2]). Our standard pass pipeline, Reassociation
effectively canonicalizes towards this form. So for reduction
vectorization to be wildly applicable, we need this feature.
This change enables the use of a non-empty ReorderIndices structure -
which is effectively required for out of order loads or gathers - while
leaving the ReuseShuffleIndices mechanism unused and disabled. If I've
understood the code structure, the former is used when describing
implicit shuffles required by the vectorization strategy (i.e. loading
elements 0,1,3,2 in the order 0,1,2,3 and then shuffling later), while
the later is used when trying to optimize explode/buildvectors (called
gathers in this code).
I audited all the code enabled by this change, but can't claim to
deeply understand most of it. I added a couple of bailouts in places
which appeared to be difficult to audit and optional optimizations. I've
tried to do so in the least risky way I can, but am not completely
confident in this change. Careful review appreciated.1 parent bded3b3 commit 63e8a1b
File tree
4 files changed
+89
-71
lines changed- llvm
- lib/Transforms/Vectorize
- test/Transforms/SLPVectorizer
- AArch64
- RISCV
- X86
4 files changed
+89
-71
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3388 | 3388 | | |
3389 | 3389 | | |
3390 | 3390 | | |
| 3391 | + | |
| 3392 | + | |
| 3393 | + | |
| 3394 | + | |
3391 | 3395 | | |
3392 | 3396 | | |
3393 | 3397 | | |
| |||
3452 | 3456 | | |
3453 | 3457 | | |
3454 | 3458 | | |
3455 | | - | |
| 3459 | + | |
3456 | 3460 | | |
3457 | | - | |
3458 | | - | |
3459 | | - | |
3460 | 3461 | | |
3461 | 3462 | | |
3462 | 3463 | | |
| |||
4731 | 4732 | | |
4732 | 4733 | | |
4733 | 4734 | | |
4734 | | - | |
4735 | | - | |
4736 | | - | |
4737 | | - | |
4738 | | - | |
4739 | | - | |
4740 | 4735 | | |
4741 | 4736 | | |
4742 | 4737 | | |
| |||
4824 | 4819 | | |
4825 | 4820 | | |
4826 | 4821 | | |
| 4822 | + | |
| 4823 | + | |
| 4824 | + | |
| 4825 | + | |
| 4826 | + | |
| 4827 | + | |
4827 | 4828 | | |
4828 | 4829 | | |
4829 | 4830 | | |
| |||
5195 | 5196 | | |
5196 | 5197 | | |
5197 | 5198 | | |
5198 | | - | |
5199 | | - | |
5200 | | - | |
5201 | | - | |
5202 | 5199 | | |
5203 | 5200 | | |
5204 | 5201 | | |
| 5202 | + | |
| 5203 | + | |
| 5204 | + | |
| 5205 | + | |
5205 | 5206 | | |
5206 | 5207 | | |
5207 | 5208 | | |
| |||
5424 | 5425 | | |
5425 | 5426 | | |
5426 | 5427 | | |
5427 | | - | |
| 5428 | + | |
5428 | 5429 | | |
5429 | 5430 | | |
5430 | | - | |
5431 | | - | |
| 5431 | + | |
| 5432 | + | |
| 5433 | + | |
| 5434 | + | |
| 5435 | + | |
| 5436 | + | |
5432 | 5437 | | |
5433 | 5438 | | |
5434 | 5439 | | |
| |||
5580 | 5585 | | |
5581 | 5586 | | |
5582 | 5587 | | |
5583 | | - | |
| 5588 | + | |
5584 | 5589 | | |
5585 | 5590 | | |
5586 | 5591 | | |
| |||
5752 | 5757 | | |
5753 | 5758 | | |
5754 | 5759 | | |
5755 | | - | |
5756 | | - | |
5757 | | - | |
5758 | | - | |
5759 | 5760 | | |
5760 | 5761 | | |
5761 | 5762 | | |
| |||
5927 | 5928 | | |
5928 | 5929 | | |
5929 | 5930 | | |
5930 | | - | |
5931 | | - | |
5932 | | - | |
5933 | 5931 | | |
5934 | 5932 | | |
5935 | 5933 | | |
| |||
Lines changed: 8 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
194 | | - | |
195 | | - | |
| 194 | + | |
196 | 195 | | |
197 | 196 | | |
198 | 197 | | |
199 | | - | |
| 198 | + | |
| 199 | + | |
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
266 | | - | |
| 266 | + | |
| 267 | + | |
267 | 268 | | |
268 | 269 | | |
269 | 270 | | |
| |||
566 | 567 | | |
567 | 568 | | |
568 | 569 | | |
569 | | - | |
570 | | - | |
| 570 | + | |
571 | 571 | | |
572 | 572 | | |
573 | | - | |
| 573 | + | |
| 574 | + | |
574 | 575 | | |
575 | 576 | | |
576 | 577 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
557 | 557 | | |
558 | 558 | | |
559 | 559 | | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
564 | | - | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | | - | |
569 | | - | |
570 | | - | |
571 | | - | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
579 | 588 | | |
580 | 589 | | |
581 | 590 | | |
| |||
653 | 662 | | |
654 | 663 | | |
655 | 664 | | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | | - | |
661 | | - | |
662 | | - | |
663 | | - | |
664 | | - | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
672 | 690 | | |
673 | 691 | | |
674 | 692 | | |
| |||
Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
194 | | - | |
| 193 | + | |
195 | 194 | | |
196 | 195 | | |
197 | 196 | | |
198 | | - | |
| 197 | + | |
| 198 | + | |
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | | - | |
| 265 | + | |
| 266 | + | |
266 | 267 | | |
267 | 268 | | |
268 | 269 | | |
| |||
0 commit comments