@@ -6725,9 +6725,9 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
6725
6725
bool IsScatterVectorizeUserTE =
6726
6726
UserTreeIdx.UserTE &&
6727
6727
UserTreeIdx.UserTE->State == TreeEntry::ScatterVectorize;
6728
- bool AreAllSameInsts =
6729
- (S.getOpcode() && allSameBlock(VL)) ||
6730
- (S.OpValue->getType()->isPointerTy() && IsScatterVectorizeUserTE &&
6728
+ bool AreAllSameBlock = S.getOpcode() && allSameBlock(VL);
6729
+ bool AreScatterAllGEPSameBlock =
6730
+ (IsScatterVectorizeUserTE && S.OpValue->getType()->isPointerTy() &&
6731
6731
VL.size() > 2 &&
6732
6732
all_of(VL,
6733
6733
[&BB](Value *V) {
@@ -6741,6 +6741,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
6741
6741
BB &&
6742
6742
sortPtrAccesses(VL, UserTreeIdx.UserTE->getMainOp()->getType(), *DL, *SE,
6743
6743
SortedIndices));
6744
+ bool AreAllSameInsts = AreAllSameBlock || AreScatterAllGEPSameBlock;
6744
6745
if (!AreAllSameInsts || allConstant(VL) || isSplat(VL) ||
6745
6746
(isa<InsertElementInst, ExtractValueInst, ExtractElementInst>(
6746
6747
S.OpValue) &&
@@ -6820,9 +6821,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
6820
6821
6821
6822
// Special processing for sorted pointers for ScatterVectorize node with
6822
6823
// constant indeces only.
6823
- if (AreAllSameInsts && UserTreeIdx.UserTE &&
6824
- UserTreeIdx.UserTE->State == TreeEntry::ScatterVectorize &&
6825
- !(S.getOpcode() && allSameBlock(VL))) {
6824
+ if (!AreAllSameBlock && AreScatterAllGEPSameBlock) {
6826
6825
assert(S.OpValue->getType()->isPointerTy() &&
6827
6826
count_if(VL, IsaPred<GetElementPtrInst>) >= 2 &&
6828
6827
"Expected pointers only.");
0 commit comments