Skip to content

Commit fc06d20

Browse files
committed
replace the for statement with std::iota and relocate the conditional statement
1 parent 054c1f4 commit fc06d20

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,15 +337,14 @@ bool VectorCombine::vectorizeLoadInsert(Instruction &I) {
337337
SmallVector<int> Mask;
338338
assert(OffsetEltIndex + VectorRange < MinVecNumElts &&
339339
"Address offset too big");
340-
if (!NeedCast) {
340+
if (NeedCast) {
341+
Mask.assign(MinVecNumElts, PoisonMaskElem);
342+
std::iota(Mask.begin(), Mask.begin() + VectorRange, OffsetEltIndex);
343+
} else {
341344
auto *Ty = cast<FixedVectorType>(I.getType());
342345
unsigned OutputNumElts = Ty->getNumElements();
343346
Mask.assign(OutputNumElts, PoisonMaskElem);
344347
Mask[0] = OffsetEltIndex;
345-
} else {
346-
Mask.assign(MinVecNumElts, PoisonMaskElem);
347-
for (unsigned InsertPos = 0; InsertPos < VectorRange; InsertPos++)
348-
Mask[InsertPos] = OffsetEltIndex++;
349348
}
350349

351350
if (OffsetEltIndex)

0 commit comments

Comments
 (0)