[LV] Use separate index to access StoredValues in vectorizeInterleave.

StoredValues only has entries for members of the interleave group. If
there are gaps, then using the index i here will either access a wrong
entry or be out-of-bounds.

Instead use a dedicated index that only gets incremented for members of
the interleave group.

Fixes #59090.
This commit is contained in:
Florian Hahn
2022-11-25 15:28:04 +00:00
parent 480cd780d6
commit ed2fdace89
2 changed files with 128 additions and 1 deletions

View File

@@ -2695,6 +2695,7 @@ void InnerLoopVectorizer::vectorizeInterleaveGroup(
for (unsigned Part = 0; Part < UF; Part++) {
// Collect the stored vector from each member.
SmallVector<Value *, 4> StoredVecs;
unsigned StoredIdx = 0;
for (unsigned i = 0; i < InterleaveFactor; i++) {
assert((Group->getMember(i) || MaskForGaps) &&
"Fail to get a member from an interleaved store group");
@@ -2707,7 +2708,8 @@ void InnerLoopVectorizer::vectorizeInterleaveGroup(
continue;
}
Value *StoredVec = State.get(StoredValues[i], Part);
Value *StoredVec = State.get(StoredValues[StoredIdx], Part);
++StoredIdx;
if (Group->isReverse())
StoredVec = Builder.CreateVectorReverse(StoredVec, "reverse");