Skip to content

Commit 14b36af

Browse files
author
git apple-llvm automerger
committed
Merge commit '3fd682863968' from llvm.org/main into next
2 parents e4e525b + 3fd6828 commit 14b36af

File tree

1 file changed

+15
-32
lines changed

1 file changed

+15
-32
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17846,6 +17846,17 @@ class BoUpSLP::ShuffleInstructionBuilder final : public BaseShuffleAnalysis {
1784617846
IsSigned.value_or(!isKnownNonNegative(V, SimplifyQuery(*R.DL))));
1784717847
}
1784817848

17849+
Value *getVectorizedValue(const TreeEntry &E) {
17850+
Value *Vec = E.VectorizedValue;
17851+
if (!Vec->getType()->isIntOrIntVectorTy())
17852+
return Vec;
17853+
return castToScalarTyElem(Vec, any_of(E.Scalars, [&](Value *V) {
17854+
return !isa<PoisonValue>(V) &&
17855+
!isKnownNonNegative(
17856+
V, SimplifyQuery(*R.DL));
17857+
}));
17858+
}
17859+
1784917860
public:
1785017861
ShuffleInstructionBuilder(Type *ScalarTy, IRBuilderBase &Builder, BoUpSLP &R)
1785117862
: BaseShuffleAnalysis(ScalarTy), Builder(Builder), R(R) {}
@@ -18012,35 +18023,14 @@ class BoUpSLP::ShuffleInstructionBuilder final : public BaseShuffleAnalysis {
1801218023
/// Adds 2 input vectors (in form of tree entries) and the mask for their
1801318024
/// shuffling.
1801418025
void add(const TreeEntry &E1, const TreeEntry &E2, ArrayRef<int> Mask) {
18015-
Value *V1 = E1.VectorizedValue;
18016-
if (V1->getType()->isIntOrIntVectorTy())
18017-
V1 = castToScalarTyElem(V1, any_of(E1.Scalars, [&](Value *V) {
18018-
if (isa<PoisonValue>(V))
18019-
return false;
18020-
return !isKnownNonNegative(
18021-
V, SimplifyQuery(*R.DL));
18022-
}));
18023-
Value *V2 = E2.VectorizedValue;
18024-
if (V2->getType()->isIntOrIntVectorTy())
18025-
V2 = castToScalarTyElem(V2, any_of(E2.Scalars, [&](Value *V) {
18026-
if (isa<PoisonValue>(V))
18027-
return false;
18028-
return !isKnownNonNegative(
18029-
V, SimplifyQuery(*R.DL));
18030-
}));
18026+
Value *V1 = getVectorizedValue(E1);
18027+
Value *V2 = getVectorizedValue(E2);
1803118028
add(V1, V2, Mask);
1803218029
}
1803318030
/// Adds single input vector (in form of tree entry) and the mask for its
1803418031
/// shuffling.
1803518032
void add(const TreeEntry &E1, ArrayRef<int> Mask) {
18036-
Value *V1 = E1.VectorizedValue;
18037-
if (V1->getType()->isIntOrIntVectorTy())
18038-
V1 = castToScalarTyElem(V1, any_of(E1.Scalars, [&](Value *V) {
18039-
if (isa<PoisonValue>(V))
18040-
return false;
18041-
return !isKnownNonNegative(
18042-
V, SimplifyQuery(*R.DL));
18043-
}));
18033+
Value *V1 = getVectorizedValue(E1);
1804418034
add(V1, Mask);
1804518035
}
1804618036
/// Adds 2 input vectors and the mask for their shuffling.
@@ -18189,14 +18179,7 @@ class BoUpSLP::ShuffleInstructionBuilder final : public BaseShuffleAnalysis {
1818918179
auto CreateSubVectors = [&](Value *Vec,
1819018180
SmallVectorImpl<int> &CommonMask) {
1819118181
for (auto [E, Idx] : SubVectors) {
18192-
Value *V = E->VectorizedValue;
18193-
if (V->getType()->isIntOrIntVectorTy())
18194-
V = castToScalarTyElem(V, any_of(E->Scalars, [&](Value *V) {
18195-
if (isa<PoisonValue>(V))
18196-
return false;
18197-
return !isKnownNonNegative(
18198-
V, SimplifyQuery(*R.DL));
18199-
}));
18182+
Value *V = getVectorizedValue(*E);
1820018183
unsigned InsertionIndex = Idx * getNumElements(ScalarTy);
1820118184
// Use scalar version of the SCalarType to correctly handle shuffles
1820218185
// for revectorization. The revectorization mode operates by the

0 commit comments

Comments
 (0)