Skip to content

Commit 74396f5

Browse files
author
Davide Italiano
committed
[SLP]Fix PR58863: Mask index beyond mask size for non-power-2 insertelement analysis.
Need to check if the insertelement mask size is reached during cost analysis to avoid compiler crash. Differential Revision: https://reviews.llvm.org/D137639
1 parent 0e1198f commit 74396f5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6458,6 +6458,8 @@ InstructionCost BoUpSLP::getEntryCost(const TreeEntry *E,
64586458
Mask[I] = I + VecSz;
64596459
for (unsigned I = OffsetEnd + 1 - Offset; I < VecSz; ++I)
64606460
Mask[I] = InMask.test(I) ? UndefMaskElem : I;
6461+
Mask[I] =
6462+
((I >= InMask.size()) || InMask.test(I)) ? UndefMaskElem : I;
64616463
Cost += TTI->getShuffleCost(TTI::SK_PermuteTwoSrc, InsertVecTy, Mask);
64626464
}
64636465
}

0 commit comments

Comments
 (0)