@@ -4104,6 +4104,8 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom) {
4104
4104
// No need to reorder if need to shuffle reuses, still need to shuffle the
4105
4105
// node.
4106
4106
if (!TE.ReuseShuffleIndices.empty()) {
4107
+ if (isSplat(TE.Scalars))
4108
+ return std::nullopt;
4107
4109
// Check if reuse shuffle indices can be improved by reordering.
4108
4110
// For this, check that reuse mask is "clustered", i.e. each scalar values
4109
4111
// is used once in each submask of size <number_of_scalars>.
@@ -4283,11 +4285,13 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom) {
4283
4285
return std::move(Order);
4284
4286
}
4285
4287
}
4286
- if (std::optional<OrdersType> CurrentOrder = findReusedOrderedScalars (TE))
4287
- return CurrentOrder ;
4288
+ if (isSplat (TE.Scalars ))
4289
+ return std::nullopt ;
4288
4290
if (TE.Scalars.size() >= 4)
4289
4291
if (std::optional<OrdersType> Order = findPartiallyOrderedLoads(TE))
4290
4292
return Order;
4293
+ if (std::optional<OrdersType> CurrentOrder = findReusedOrderedScalars(TE))
4294
+ return CurrentOrder;
4291
4295
}
4292
4296
return std::nullopt;
4293
4297
}
@@ -4743,7 +4747,7 @@ void BoUpSLP::reorderBottomToTop(bool IgnoreReorder) {
4743
4747
continue;
4744
4748
if (!OpTE->ReuseShuffleIndices.empty() && !GathersToOrders.count(OpTE))
4745
4749
continue;
4746
- const auto & Order = [OpTE, &GathersToOrders ]() -> const OrdersType & {
4750
+ const auto Order = [& ]() -> const OrdersType {
4747
4751
if (OpTE->State == TreeEntry::NeedToGather ||
4748
4752
!OpTE->ReuseShuffleIndices.empty())
4749
4753
return GathersToOrders.find(OpTE)->second;
@@ -4775,8 +4779,7 @@ void BoUpSLP::reorderBottomToTop(bool IgnoreReorder) {
4775
4779
OrdersUses.insert(std::make_pair(Order, 0)).first->second += NumOps;
4776
4780
}
4777
4781
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) {
4780
4783
if (!TE->ReorderIndices.empty() || !TE->ReuseShuffleIndices.empty() ||
4781
4784
(TE->State == TreeEntry::Vectorize && TE->isAltShuffle()) ||
4782
4785
(IgnoreReorder && TE->Idx == 0))
@@ -9394,6 +9397,8 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
9394
9397
} else {
9395
9398
TEInsertBlock = TEInsertPt->getParent();
9396
9399
}
9400
+ if (!DT->isReachableFromEntry(TEInsertBlock))
9401
+ return std::nullopt;
9397
9402
auto *NodeUI = DT->getNode(TEInsertBlock);
9398
9403
assert(NodeUI && "Should only process reachable instructions");
9399
9404
SmallPtrSet<Value *, 4> GatheredScalars(VL.begin(), VL.end());
0 commit comments