@@ -16292,7 +16292,7 @@ Value *BoUpSLP::gather(
1629216292 if (auto *SV = dyn_cast<ShuffleVectorInst>(InsElt);
1629316293 SV && SV->getOperand(0) != V && SV->getOperand(1) != V) {
1629416294 // Find shufflevector, caused by resize.
16295- auto FindOperand = [& ](Value *Vec, Value *V) -> Instruction * {
16295+ auto FindOperand = [](Value *Vec, Value *V) -> Instruction * {
1629616296 if (auto *SV = dyn_cast<ShuffleVectorInst>(Vec)) {
1629716297 if (SV->getOperand(0) == V)
1629816298 return SV;
@@ -16301,6 +16301,7 @@ Value *BoUpSLP::gather(
1630116301 }
1630216302 return nullptr;
1630316303 };
16304+ InsElt = nullptr;
1630416305 if (Instruction *User = FindOperand(SV->getOperand(0), V))
1630516306 InsElt = User;
1630616307 else if (Instruction *User = FindOperand(SV->getOperand(1), V))
@@ -16877,6 +16878,11 @@ class BoUpSLP::ShuffleInstructionBuilder final : public BaseShuffleAnalysis {
1687716878 V, SimplifyQuery(*R.DL));
1687816879 }));
1687916880 unsigned InsertionIndex = Idx * getNumElements(ScalarTy);
16881+ // Use scalar version of the SCalarType to correctly handle shuffles
16882+ // for revectorization. The revectorization mode operates by the
16883+ // vectors, but here we need to operate on the scalars, because the
16884+ // masks were already transformed for the vector elements and we don't
16885+ // need doing this transformation again.
1688016886 Type *OrigScalarTy = ScalarTy;
1688116887 ScalarTy = ScalarTy->getScalarType();
1688216888 Vec = createInsertVector(
0 commit comments