Commit a6300f7
committed
[SLP] Improve block traversal in getSpillCost()
This is a WIP patch due to the compilation time regressions, up to 7% on
gcc_r/gcc_s.
Previously, getSpillCost would skip in between blocks when traversing
instructions backward. If one of the missing blocks has a function call,
the existing logic would lead to incorrect spill cost calculations.
The new implementation:
- Uses post_order traversal to visit blocks
- Tracks live entries across basic blocks
- Computes reachable blocks once upfront using depth_first_ext
- Maintains correct cost calculation for diamond-shaped control flow
Performance improvements:
- Reduces execution time of SPEC CPU benchmark 544.nab_r by 9.92%
- Reduces code size of 508.namd by 1.73%
This optimization improves vectorization decisions by making spill cost
estimation more accurate, particularly for code with complex control flow.1 parent e55f1a7 commit a6300f7
File tree
3 files changed
+80
-84
lines changed- llvm
- lib/Transforms/Vectorize
- test/Transforms/SLPVectorizer/RISCV
3 files changed
+80
-84
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12415 | 12415 | | |
12416 | 12416 | | |
12417 | 12417 | | |
12418 | | - | |
12419 | | - | |
12420 | | - | |
12421 | | - | |
12422 | | - | |
12423 | | - | |
12424 | | - | |
12425 | | - | |
12426 | | - | |
12427 | | - | |
12428 | | - | |
12429 | | - | |
12430 | | - | |
12431 | | - | |
12432 | | - | |
12433 | | - | |
12434 | | - | |
12435 | | - | |
12436 | | - | |
12437 | | - | |
12438 | | - | |
12439 | | - | |
12440 | | - | |
12441 | | - | |
12442 | | - | |
12443 | | - | |
12444 | | - | |
12445 | | - | |
12446 | 12418 | | |
12447 | | - | |
12448 | | - | |
12449 | | - | |
| 12419 | + | |
| 12420 | + | |
| 12421 | + | |
| 12422 | + | |
| 12423 | + | |
| 12424 | + | |
| 12425 | + | |
12450 | 12426 | | |
12451 | | - | |
| 12427 | + | |
| 12428 | + | |
| 12429 | + | |
| 12430 | + | |
12452 | 12431 | | |
12453 | | - | |
12454 | | - | |
12455 | | - | |
12456 | | - | |
12457 | | - | |
12458 | | - | |
12459 | | - | |
12460 | | - | |
| 12432 | + | |
| 12433 | + | |
| 12434 | + | |
| 12435 | + | |
12461 | 12436 | | |
12462 | | - | |
12463 | | - | |
12464 | | - | |
12465 | | - | |
12466 | | - | |
12467 | | - | |
12468 | | - | |
| 12437 | + | |
12469 | 12438 | | |
12470 | | - | |
12471 | | - | |
12472 | | - | |
12473 | | - | |
12474 | | - | |
12475 | | - | |
12476 | | - | |
12477 | | - | |
12478 | | - | |
12479 | | - | |
| 12439 | + | |
| 12440 | + | |
| 12441 | + | |
| 12442 | + | |
| 12443 | + | |
| 12444 | + | |
| 12445 | + | |
| 12446 | + | |
| 12447 | + | |
| 12448 | + | |
| 12449 | + | |
| 12450 | + | |
| 12451 | + | |
| 12452 | + | |
| 12453 | + | |
| 12454 | + | |
| 12455 | + | |
| 12456 | + | |
| 12457 | + | |
| 12458 | + | |
| 12459 | + | |
12480 | 12460 | | |
12481 | 12461 | | |
12482 | 12462 | | |
| |||
12497 | 12477 | | |
12498 | 12478 | | |
12499 | 12479 | | |
12500 | | - | |
12501 | | - | |
12502 | | - | |
12503 | | - | |
12504 | | - | |
12505 | | - | |
| 12480 | + | |
| 12481 | + | |
| 12482 | + | |
| 12483 | + | |
| 12484 | + | |
| 12485 | + | |
| 12486 | + | |
| 12487 | + | |
| 12488 | + | |
| 12489 | + | |
| 12490 | + | |
| 12491 | + | |
12506 | 12492 | | |
12507 | | - | |
12508 | | - | |
12509 | | - | |
12510 | | - | |
12511 | | - | |
12512 | | - | |
12513 | | - | |
12514 | | - | |
| 12493 | + | |
| 12494 | + | |
| 12495 | + | |
12515 | 12496 | | |
12516 | | - | |
12517 | 12497 | | |
12518 | | - | |
12519 | | - | |
12520 | 12498 | | |
12521 | 12499 | | |
12522 | 12500 | | |
| |||
Lines changed: 12 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1740 | 1740 | | |
1741 | 1741 | | |
1742 | 1742 | | |
1743 | | - | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
1744 | 1746 | | |
1745 | 1747 | | |
1746 | 1748 | | |
| |||
1751 | 1753 | | |
1752 | 1754 | | |
1753 | 1755 | | |
1754 | | - | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
1755 | 1759 | | |
1756 | 1760 | | |
1757 | 1761 | | |
1758 | 1762 | | |
1759 | | - | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
1760 | 1766 | | |
1761 | 1767 | | |
1762 | 1768 | | |
| |||
1767 | 1773 | | |
1768 | 1774 | | |
1769 | 1775 | | |
1770 | | - | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
1771 | 1779 | | |
1772 | 1780 | | |
1773 | 1781 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
23 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
24 | 28 | | |
25 | 29 | | |
26 | 30 | | |
| |||
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
53 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
54 | 60 | | |
55 | 61 | | |
56 | | - | |
| 62 | + | |
| 63 | + | |
57 | 64 | | |
58 | 65 | | |
59 | 66 | | |
60 | 67 | | |
61 | 68 | | |
62 | 69 | | |
63 | 70 | | |
64 | | - | |
65 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
66 | 76 | | |
67 | 77 | | |
68 | 78 | | |
| |||
0 commit comments