Commit 6f31e57
committed
[VPlan] Introduce multi-branch recipe, use for multi-exit loops (WIP).
This patch introduces a new BranchMultipleConds VPInstruction that
takes multiple conditions and branches to the first successor if the
first operand is true, to the second successor if the second condition
is true and to the region header if neither is true. At the moment it
only supports 2 conditions, but it can be extended in the future.
This may serve as an alternative to changing VPRegionBlock to allow
multiple exiting blocks and keep it single-entry-single-exit. With
BranchMultipleConds, we still leave a region via a single exiting
block, but can have more than 2 destinations (similar idea to switch in
LLVM IR). The new recipe allows to precisely model edges and conditions
leaving the vector loop region.
BranchMultipleConds also allows predicating instructions in blocks
after any early exit, i.e. also allows later stores.
See llvm/test/Transforms/LoopVectorize/X86/multi-exit-vplan.ll for
an example VPlan and llvm/test/Transforms/LoopVectorize/X86/multi-exit-codegen.ll
for example predicated codegen.
The patch also contains logic to construct VPlans using
BranchMultipleConds for simple loops with 2 exit blocks instead of
requiring a scalar tail. To logic to detect such cases is a bit rough
around the edges and mainly to test the new recipes end-to-end.
This may serve as an alternative to #108563
that would allow us to keep the single-entry-single-exit property and
support predication between early exits and latches.1 parent 79d5c6a commit 6f31e57
File tree
12 files changed
+533
-63
lines changed- llvm
- include/llvm/Transforms/Vectorize
- lib/Transforms/Vectorize
- test/Transforms/LoopVectorize/X86
12 files changed
+533
-63
lines changedLines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
| 290 | + | |
| 291 | + | |
290 | 292 | | |
291 | 293 | | |
292 | 294 | | |
| |||
Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
| |||
1378 | 1381 | | |
1379 | 1382 | | |
1380 | 1383 | | |
| 1384 | + | |
| 1385 | + | |
1381 | 1386 | | |
1382 | 1387 | | |
1383 | 1388 | | |
| |||
1514 | 1519 | | |
1515 | 1520 | | |
1516 | 1521 | | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
1517 | 1551 | | |
1518 | 1552 | | |
1519 | 1553 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1362 | 1362 | | |
1363 | 1363 | | |
1364 | 1364 | | |
1365 | | - | |
1366 | | - | |
1367 | | - | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
1368 | 1370 | | |
1369 | 1371 | | |
1370 | 1372 | | |
| |||
2535 | 2537 | | |
2536 | 2538 | | |
2537 | 2539 | | |
2538 | | - | |
2539 | | - | |
| 2540 | + | |
| 2541 | + | |
| 2542 | + | |
| 2543 | + | |
| 2544 | + | |
| 2545 | + | |
| 2546 | + | |
| 2547 | + | |
| 2548 | + | |
| 2549 | + | |
| 2550 | + | |
2540 | 2551 | | |
2541 | 2552 | | |
2542 | 2553 | | |
| |||
2910 | 2921 | | |
2911 | 2922 | | |
2912 | 2923 | | |
2913 | | - | |
| 2924 | + | |
| 2925 | + | |
2914 | 2926 | | |
2915 | 2927 | | |
2916 | 2928 | | |
| |||
3554 | 3566 | | |
3555 | 3567 | | |
3556 | 3568 | | |
3557 | | - | |
| 3569 | + | |
| 3570 | + | |
3558 | 3571 | | |
3559 | 3572 | | |
3560 | 3573 | | |
| |||
7643 | 7656 | | |
7644 | 7657 | | |
7645 | 7658 | | |
7646 | | - | |
7647 | | - | |
7648 | | - | |
7649 | | - | |
7650 | | - | |
7651 | | - | |
| 7659 | + | |
| 7660 | + | |
| 7661 | + | |
| 7662 | + | |
| 7663 | + | |
| 7664 | + | |
| 7665 | + | |
| 7666 | + | |
| 7667 | + | |
7652 | 7668 | | |
7653 | 7669 | | |
7654 | 7670 | | |
| |||
7674 | 7690 | | |
7675 | 7691 | | |
7676 | 7692 | | |
| 7693 | + | |
7677 | 7694 | | |
7678 | 7695 | | |
7679 | 7696 | | |
| |||
7686 | 7703 | | |
7687 | 7704 | | |
7688 | 7705 | | |
7689 | | - | |
7690 | | - | |
7691 | | - | |
7692 | | - | |
7693 | | - | |
7694 | | - | |
7695 | | - | |
7696 | | - | |
7697 | | - | |
| 7706 | + | |
| 7707 | + | |
| 7708 | + | |
| 7709 | + | |
| 7710 | + | |
| 7711 | + | |
| 7712 | + | |
| 7713 | + | |
| 7714 | + | |
| 7715 | + | |
| 7716 | + | |
7698 | 7717 | | |
7699 | 7718 | | |
7700 | 7719 | | |
| |||
8079 | 8098 | | |
8080 | 8099 | | |
8081 | 8100 | | |
8082 | | - | |
| 8101 | + | |
8083 | 8102 | | |
8084 | 8103 | | |
8085 | 8104 | | |
| |||
8729 | 8748 | | |
8730 | 8749 | | |
8731 | 8750 | | |
| 8751 | + | |
| 8752 | + | |
8732 | 8753 | | |
8733 | 8754 | | |
8734 | 8755 | | |
| |||
8814 | 8835 | | |
8815 | 8836 | | |
8816 | 8837 | | |
| 8838 | + | |
| 8839 | + | |
8817 | 8840 | | |
8818 | 8841 | | |
8819 | 8842 | | |
| |||
9100 | 9123 | | |
9101 | 9124 | | |
9102 | 9125 | | |
| 9126 | + | |
| 9127 | + | |
| 9128 | + | |
| 9129 | + | |
| 9130 | + | |
9103 | 9131 | | |
9104 | 9132 | | |
9105 | 9133 | | |
| |||
9231 | 9259 | | |
9232 | 9260 | | |
9233 | 9261 | | |
9234 | | - | |
9235 | | - | |
9236 | 9262 | | |
9237 | 9263 | | |
9238 | 9264 | | |
| |||
9251 | 9277 | | |
9252 | 9278 | | |
9253 | 9279 | | |
9254 | | - | |
9255 | | - | |
9256 | 9280 | | |
9257 | 9281 | | |
9258 | 9282 | | |
| |||
9357 | 9381 | | |
9358 | 9382 | | |
9359 | 9383 | | |
| 9384 | + | |
| 9385 | + | |
| 9386 | + | |
| 9387 | + | |
9360 | 9388 | | |
9361 | 9389 | | |
9362 | 9390 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
474 | 474 | | |
475 | 475 | | |
476 | 476 | | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
477 | 485 | | |
478 | 486 | | |
479 | 487 | | |
| |||
601 | 609 | | |
602 | 610 | | |
603 | 611 | | |
604 | | - | |
605 | | - | |
606 | | - | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
607 | 617 | | |
608 | 618 | | |
609 | 619 | | |
| |||
908 | 918 | | |
909 | 919 | | |
910 | 920 | | |
911 | | - | |
912 | 921 | | |
| 922 | + | |
913 | 923 | | |
914 | 924 | | |
915 | 925 | | |
| |||
923 | 933 | | |
924 | 934 | | |
925 | 935 | | |
926 | | - | |
927 | | - | |
928 | | - | |
929 | | - | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
930 | 944 | | |
931 | 945 | | |
932 | 946 | | |
| |||
1035 | 1049 | | |
1036 | 1050 | | |
1037 | 1051 | | |
1038 | | - | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
1039 | 1055 | | |
1040 | 1056 | | |
1041 | 1057 | | |
| |||
1069 | 1085 | | |
1070 | 1086 | | |
1071 | 1087 | | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
1072 | 1092 | | |
1073 | 1093 | | |
1074 | 1094 | | |
| |||
1095 | 1115 | | |
1096 | 1116 | | |
1097 | 1117 | | |
1098 | | - | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
1099 | 1122 | | |
1100 | 1123 | | |
1101 | 1124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1239 | 1239 | | |
1240 | 1240 | | |
1241 | 1241 | | |
| 1242 | + | |
1242 | 1243 | | |
1243 | 1244 | | |
1244 | 1245 | | |
| |||
1249 | 1250 | | |
1250 | 1251 | | |
1251 | 1252 | | |
| 1253 | + | |
1252 | 1254 | | |
1253 | 1255 | | |
1254 | 1256 | | |
| |||
1370 | 1372 | | |
1371 | 1373 | | |
1372 | 1374 | | |
| 1375 | + | |
1373 | 1376 | | |
1374 | 1377 | | |
1375 | 1378 | | |
| |||
0 commit comments