@@ -3045,7 +3045,9 @@ class BoUpSLP {
3045
3045
3046
3046
/// \returns a vector from a collection of scalars in \p VL. if \p Root is not
3047
3047
/// specified, the starting vector value is poison.
3048
- Value *gather(ArrayRef<Value *> VL, Value *Root, Type *ScalarTy);
3048
+ Value *
3049
+ gather(ArrayRef<Value *> VL, Value *Root, Type *ScalarTy,
3050
+ function_ref<Value *(Value *, Value *, ArrayRef<int>)> CreateShuffle);
3049
3051
3050
3052
/// \returns whether the VectorizableTree is fully vectorizable and will
3051
3053
/// be beneficial even the tree height is tiny.
@@ -9167,8 +9169,9 @@ class BaseShuffleAnalysis {
9167
9169
int VF = Mask.size();
9168
9170
if (auto *FTy = dyn_cast<FixedVectorType>(V1->getType()))
9169
9171
VF = FTy->getNumElements();
9170
- if (V2 &&
9171
- !isUndefVector(V2, buildUseMask(VF, Mask, UseMask::SecondArg)).all()) {
9172
+ if (V2 && !isUndefVector</*IsPoisonOnly=*/true>(
9173
+ V2, buildUseMask(VF, Mask, UseMask::SecondArg))
9174
+ .all()) {
9172
9175
// Peek through shuffles.
9173
9176
Value *Op1 = V1;
9174
9177
Value *Op2 = V2;
@@ -13454,7 +13457,9 @@ void BoUpSLP::setInsertPointAfterBundle(const TreeEntry *E) {
13454
13457
Builder.SetCurrentDebugLocation(Front->getDebugLoc());
13455
13458
}
13456
13459
13457
- Value *BoUpSLP::gather(ArrayRef<Value *> VL, Value *Root, Type *ScalarTy) {
13460
+ Value *BoUpSLP::gather(
13461
+ ArrayRef<Value *> VL, Value *Root, Type *ScalarTy,
13462
+ function_ref<Value *(Value *, Value *, ArrayRef<int>)> CreateShuffle) {
13458
13463
// List of instructions/lanes from current block and/or the blocks which are
13459
13464
// part of the current loop. These instructions will be inserted at the end to
13460
13465
// make it possible to optimize loops and hoist invariant instructions out of
@@ -13560,7 +13565,7 @@ Value *BoUpSLP::gather(ArrayRef<Value *> VL, Value *Root, Type *ScalarTy) {
13560
13565
if (isa<PoisonValue>(Vec)) {
13561
13566
Vec = OriginalRoot;
13562
13567
} else {
13563
- Vec = Builder.CreateShuffleVector (Root, Vec, Mask);
13568
+ Vec = CreateShuffle (Root, Vec, Mask);
13564
13569
if (auto *OI = dyn_cast<Instruction>(OriginalRoot);
13565
13570
OI && OI->hasNUses(0))
13566
13571
eraseInstruction(OI);
@@ -14022,7 +14027,10 @@ class BoUpSLP::ShuffleInstructionBuilder final : public BaseShuffleAnalysis {
14022
14027
}
14023
14028
Value *gather(ArrayRef<Value *> VL, unsigned MaskVF = 0,
14024
14029
Value *Root = nullptr) {
14025
- return R.gather(VL, Root, ScalarTy);
14030
+ return R.gather(VL, Root, ScalarTy,
14031
+ [&](Value *V1, Value *V2, ArrayRef<int> Mask) {
14032
+ return createShuffle(V1, V2, Mask);
14033
+ });
14026
14034
}
14027
14035
Value *createFreeze(Value *V) { return Builder.CreateFreeze(V); }
14028
14036
/// Finalize emission of the shuffles.
0 commit comments