Commit 75a0e13
committed
[CostModel] Add a DstTy to getShuffleCost
A shuffle will take two input vectors and a mask, to produce a new vector of
size <MaskElts x SrcEltTy>. Historically it has been assumed that the SrcTy and
the DstTy are the same for getShuffleCost, with that being relaxed in recent
years. If the Tp passed to getShuffleCost is the SrcTy, then the DstTy can be
calculated from the Mask elts and the src elt size, but the Mask is not always
provided and the Tp is not reliably always the SrcTy. This has led to
situations notably in the SLP vectorizer but also in the generic cost routines
where assumption about how vectors will be legalized are built into the generic
cost routines - for example whether they will widen or promote, with the cost
modelling assuming they will widen but the default lowering to promote for
integer vectors.
This patch attempts to start improving that - it originally tried to alter more
of the cost model but that too quickly became too many changes at once, so this
patch just plumbs in a DstTy to getShuffleCost so that DstTy and SrcTy can be
reliably distinguished. The callers of getShuffleCost have been updated to try
and include a DstTy that is more accurate. Otherwise it tries to be fairly
non-functional, keeping the SrcTy used as the primary type used in shuffle
cost routines, only using DstTy where it was in the past (for InsertSubVector
for example).
Some asserts have been added that help to check for consistent values when a
Mask and a DstTy are provided to getShuffleCost. Some of them took a while to
get right, and some non-mask calls might still be incorrect. Hopefully this
will provide a useful base to build more shuffles that alter size.1 parent 4373463 commit 75a0e13
File tree
25 files changed
+444
-348
lines changed- llvm
- include/llvm
- Analysis
- CodeGen
- lib
- Analysis
- Target
- AArch64
- AMDGPU
- ARM
- Hexagon
- PowerPC
- RISCV
- SystemZ
- X86
- Transforms
- Scalar
- Vectorize
25 files changed
+444
-348
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1381 | 1381 | | |
1382 | 1382 | | |
1383 | 1383 | | |
1384 | | - | |
1385 | | - | |
1386 | | - | |
1387 | | - | |
1388 | | - | |
1389 | | - | |
1390 | | - | |
1391 | | - | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
1392 | 1391 | | |
1393 | | - | |
| 1392 | + | |
| 1393 | + | |
1394 | 1394 | | |
1395 | 1395 | | |
1396 | 1396 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
710 | 710 | | |
711 | 711 | | |
712 | 712 | | |
713 | | - | |
714 | | - | |
715 | | - | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
716 | 716 | | |
717 | 717 | | |
718 | 718 | | |
| |||
1541 | 1541 | | |
1542 | 1542 | | |
1543 | 1543 | | |
1544 | | - | |
1545 | | - | |
1546 | | - | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
1547 | 1547 | | |
1548 | 1548 | | |
1549 | 1549 | | |
1550 | | - | |
| 1550 | + | |
| 1551 | + | |
1551 | 1552 | | |
1552 | 1553 | | |
1553 | 1554 | | |
| |||
1576 | 1577 | | |
1577 | 1578 | | |
1578 | 1579 | | |
1579 | | - | |
| 1580 | + | |
1580 | 1581 | | |
1581 | 1582 | | |
1582 | 1583 | | |
1583 | 1584 | | |
| 1585 | + | |
| 1586 | + | |
1584 | 1587 | | |
1585 | 1588 | | |
1586 | 1589 | | |
1587 | 1590 | | |
1588 | | - | |
| 1591 | + | |
| 1592 | + | |
1589 | 1593 | | |
1590 | 1594 | | |
1591 | 1595 | | |
1592 | 1596 | | |
1593 | | - | |
| 1597 | + | |
1594 | 1598 | | |
1595 | 1599 | | |
1596 | 1600 | | |
1597 | 1601 | | |
1598 | 1602 | | |
1599 | 1603 | | |
1600 | 1604 | | |
1601 | | - | |
1602 | | - | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
1603 | 1608 | | |
1604 | 1609 | | |
1605 | | - | |
1606 | | - | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
1607 | 1613 | | |
1608 | 1614 | | |
1609 | | - | |
1610 | | - | |
| 1615 | + | |
| 1616 | + | |
1611 | 1617 | | |
1612 | 1618 | | |
1613 | 1619 | | |
1614 | | - | |
1615 | | - | |
| 1620 | + | |
| 1621 | + | |
1616 | 1622 | | |
1617 | 1623 | | |
1618 | 1624 | | |
1619 | | - | |
1620 | | - | |
1621 | | - | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
1622 | 1628 | | |
1623 | 1629 | | |
1624 | 1630 | | |
1625 | | - | |
| 1631 | + | |
1626 | 1632 | | |
1627 | 1633 | | |
1628 | 1634 | | |
1629 | 1635 | | |
1630 | | - | |
1631 | | - | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
1632 | 1639 | | |
1633 | | - | |
1634 | | - | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
1635 | 1643 | | |
1636 | 1644 | | |
1637 | 1645 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
337 | 337 | | |
338 | 338 | | |
339 | 339 | | |
| |||
1101 | 1101 | | |
1102 | 1102 | | |
1103 | 1103 | | |
1104 | | - | |
| 1104 | + | |
1105 | 1105 | | |
1106 | 1106 | | |
1107 | 1107 | | |
1108 | | - | |
| 1108 | + | |
1109 | 1109 | | |
1110 | 1110 | | |
1111 | 1111 | | |
| |||
1116 | 1116 | | |
1117 | 1117 | | |
1118 | 1118 | | |
1119 | | - | |
| 1119 | + | |
1120 | 1120 | | |
1121 | 1121 | | |
1122 | 1122 | | |
| |||
1127 | 1127 | | |
1128 | 1128 | | |
1129 | 1129 | | |
1130 | | - | |
| 1130 | + | |
1131 | 1131 | | |
1132 | 1132 | | |
1133 | 1133 | | |
| |||
1151 | 1151 | | |
1152 | 1152 | | |
1153 | 1153 | | |
1154 | | - | |
1155 | | - | |
1156 | | - | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
1157 | 1157 | | |
1158 | | - | |
| 1158 | + | |
1159 | 1159 | | |
1160 | | - | |
| 1160 | + | |
1161 | 1161 | | |
1162 | 1162 | | |
1163 | 1163 | | |
| |||
1166 | 1166 | | |
1167 | 1167 | | |
1168 | 1168 | | |
1169 | | - | |
| 1169 | + | |
1170 | 1170 | | |
1171 | 1171 | | |
1172 | 1172 | | |
1173 | | - | |
| 1173 | + | |
1174 | 1174 | | |
1175 | 1175 | | |
1176 | | - | |
| 1176 | + | |
1177 | 1177 | | |
1178 | 1178 | | |
1179 | 1179 | | |
| |||
1910 | 1910 | | |
1911 | 1911 | | |
1912 | 1912 | | |
| 1913 | + | |
1913 | 1914 | | |
1914 | 1915 | | |
1915 | 1916 | | |
| |||
1920 | 1921 | | |
1921 | 1922 | | |
1922 | 1923 | | |
1923 | | - | |
1924 | | - | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
1925 | 1927 | | |
1926 | 1928 | | |
1927 | | - | |
| 1929 | + | |
1928 | 1930 | | |
1929 | 1931 | | |
1930 | 1932 | | |
1931 | 1933 | | |
1932 | 1934 | | |
1933 | | - | |
| 1935 | + | |
1934 | 1936 | | |
1935 | 1937 | | |
1936 | 1938 | | |
| |||
2376 | 2378 | | |
2377 | 2379 | | |
2378 | 2380 | | |
2379 | | - | |
2380 | | - | |
| 2381 | + | |
| 2382 | + | |
2381 | 2383 | | |
2382 | 2384 | | |
2383 | 2385 | | |
| |||
2961 | 2963 | | |
2962 | 2964 | | |
2963 | 2965 | | |
2964 | | - | |
2965 | | - | |
| 2966 | + | |
| 2967 | + | |
2966 | 2968 | | |
2967 | 2969 | | |
2968 | 2970 | | |
| |||
2978 | 2980 | | |
2979 | 2981 | | |
2980 | 2982 | | |
2981 | | - | |
| 2983 | + | |
2982 | 2984 | | |
2983 | 2985 | | |
2984 | 2986 | | |
| |||
3052 | 3054 | | |
3053 | 3055 | | |
3054 | 3056 | | |
3055 | | - | |
3056 | | - | |
| 3057 | + | |
| 3058 | + | |
3057 | 3059 | | |
3058 | 3060 | | |
3059 | 3061 | | |
| |||
3069 | 3071 | | |
3070 | 3072 | | |
3071 | 3073 | | |
3072 | | - | |
| 3074 | + | |
3073 | 3075 | | |
3074 | 3076 | | |
3075 | 3077 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
985 | 985 | | |
986 | 986 | | |
987 | 987 | | |
988 | | - | |
| 988 | + | |
989 | 989 | | |
990 | 990 | | |
991 | | - | |
992 | | - | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
993 | 998 | | |
994 | 999 | | |
995 | 1000 | | |
| |||
0 commit comments