Skip to content

Commit 9c4c78a

Browse files
alexey-bataevagozillon
authored andcommitted
[SLP][NFC]Add some extra checks/reorganize the code to improve compile time, NFC.
1 parent 39c902a commit 9c4c78a

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4104,6 +4104,8 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom) {
41044104
// No need to reorder if need to shuffle reuses, still need to shuffle the
41054105
// node.
41064106
if (!TE.ReuseShuffleIndices.empty()) {
4107+
if (isSplat(TE.Scalars))
4108+
return std::nullopt;
41074109
// Check if reuse shuffle indices can be improved by reordering.
41084110
// For this, check that reuse mask is "clustered", i.e. each scalar values
41094111
// is used once in each submask of size <number_of_scalars>.
@@ -4283,11 +4285,13 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom) {
42834285
return std::move(Order);
42844286
}
42854287
}
4286-
if (std::optional<OrdersType> CurrentOrder = findReusedOrderedScalars(TE))
4287-
return CurrentOrder;
4288+
if (isSplat(TE.Scalars))
4289+
return std::nullopt;
42884290
if (TE.Scalars.size() >= 4)
42894291
if (std::optional<OrdersType> Order = findPartiallyOrderedLoads(TE))
42904292
return Order;
4293+
if (std::optional<OrdersType> CurrentOrder = findReusedOrderedScalars(TE))
4294+
return CurrentOrder;
42914295
}
42924296
return std::nullopt;
42934297
}
@@ -4743,7 +4747,7 @@ void BoUpSLP::reorderBottomToTop(bool IgnoreReorder) {
47434747
continue;
47444748
if (!OpTE->ReuseShuffleIndices.empty() && !GathersToOrders.count(OpTE))
47454749
continue;
4746-
const auto &Order = [OpTE, &GathersToOrders]() -> const OrdersType & {
4750+
const auto Order = [&]() -> const OrdersType {
47474751
if (OpTE->State == TreeEntry::NeedToGather ||
47484752
!OpTE->ReuseShuffleIndices.empty())
47494753
return GathersToOrders.find(OpTE)->second;
@@ -4775,8 +4779,7 @@ void BoUpSLP::reorderBottomToTop(bool IgnoreReorder) {
47754779
OrdersUses.insert(std::make_pair(Order, 0)).first->second += NumOps;
47764780
}
47774781
auto Res = OrdersUses.insert(std::make_pair(OrdersType(), 0));
4778-
const auto &&AllowsReordering = [IgnoreReorder, &GathersToOrders](
4779-
const TreeEntry *TE) {
4782+
const auto AllowsReordering = [&](const TreeEntry *TE) {
47804783
if (!TE->ReorderIndices.empty() || !TE->ReuseShuffleIndices.empty() ||
47814784
(TE->State == TreeEntry::Vectorize && TE->isAltShuffle()) ||
47824785
(IgnoreReorder && TE->Idx == 0))
@@ -9394,6 +9397,8 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
93949397
} else {
93959398
TEInsertBlock = TEInsertPt->getParent();
93969399
}
9400+
if (!DT->isReachableFromEntry(TEInsertBlock))
9401+
return std::nullopt;
93979402
auto *NodeUI = DT->getNode(TEInsertBlock);
93989403
assert(NodeUI && "Should only process reachable instructions");
93999404
SmallPtrSet<Value *, 4> GatheredScalars(VL.begin(), VL.end());

0 commit comments

Comments
 (0)