Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 8,175 Lines • ▼ Show 20 Lines | case Instruction::InsertElement: { | ||||
GatherShuffleSeq.insert(I); | GatherShuffleSeq.insert(I); | ||||
CSEBlocks.insert(I->getParent()); | CSEBlocks.insert(I->getParent()); | ||||
} | } | ||||
} | } | ||||
SmallVector<int> InsertMask(NumElts, UndefMaskElem); | SmallVector<int> InsertMask(NumElts, UndefMaskElem); | ||||
for (unsigned I = 0; I < NumElts; I++) { | for (unsigned I = 0; I < NumElts; I++) { | ||||
if (Mask[I] != UndefMaskElem) | if (Mask[I] != UndefMaskElem) | ||||
InsertMask[Offset + I] = NumElts + I; | InsertMask[Offset + I] = I; | ||||
} | } | ||||
if (Offset != 0 || | bool IsFirstUndef = isUndefVector(FirstInsert->getOperand(0), InsertMask); | ||||
!isUndefVector(FirstInsert->getOperand(0), InsertMask)) { | if ((!IsIdentity || Offset != 0 || !IsFirstUndef) && | ||||
NumElts != NumScalars) { | |||||
if (IsFirstUndef) { | |||||
if (!ShuffleVectorInst::isIdentityMask(InsertMask)) { | |||||
V = Builder.CreateShuffleVector( | |||||
V, InsertMask, cast<Instruction>(E->Scalars.back())->getName()); | |||||
if (auto *I = dyn_cast<Instruction>(V)) { | |||||
GatherShuffleSeq.insert(I); | |||||
CSEBlocks.insert(I->getParent()); | |||||
} | |||||
// Create freeze for undef values. | |||||
if (!isa<PoisonValue>(FirstInsert->getOperand(0))) | |||||
V = Builder.CreateFreeze(V); | |||||
} | |||||
} else { | |||||
for (unsigned I = 0; I < NumElts; I++) { | for (unsigned I = 0; I < NumElts; I++) { | ||||
if (InsertMask[I] == UndefMaskElem) | if (InsertMask[I] == UndefMaskElem) | ||||
InsertMask[I] = I; | InsertMask[I] = I; | ||||
else | |||||
InsertMask[I] += NumElts; | |||||
} | } | ||||
V = Builder.CreateShuffleVector( | V = Builder.CreateShuffleVector( | ||||
FirstInsert->getOperand(0), V, InsertMask, | FirstInsert->getOperand(0), V, InsertMask, | ||||
cast<Instruction>(E->Scalars.back())->getName()); | cast<Instruction>(E->Scalars.back())->getName()); | ||||
if (auto *I = dyn_cast<Instruction>(V)) { | if (auto *I = dyn_cast<Instruction>(V)) { | ||||
GatherShuffleSeq.insert(I); | GatherShuffleSeq.insert(I); | ||||
CSEBlocks.insert(I->getParent()); | CSEBlocks.insert(I->getParent()); | ||||
} | } | ||||
} | } | ||||
} | |||||
++NumVectorInstructions; | ++NumVectorInstructions; | ||||
E->VectorizedValue = V; | E->VectorizedValue = V; | ||||
return V; | return V; | ||||
} | } | ||||
case Instruction::ZExt: | case Instruction::ZExt: | ||||
case Instruction::SExt: | case Instruction::SExt: | ||||
case Instruction::FPToUI: | case Instruction::FPToUI: | ||||
▲ Show 20 Lines • Show All 4,509 Lines • Show Last 20 Lines |