forked from OSchip/llvm-project
Factor the vector load rewriting into a more generic form.
This makes it suitable for use in rewriting memcpy in the presence of subvector memcpy intrinsics. No functionality changed. llvm-svn: 170324
This commit is contained in:
parent
3a0d5cc314
commit
769445ef03
|
@ -2388,19 +2388,24 @@ private:
|
||||||
Pass.DeadInsts.insert(I);
|
Pass.DeadInsts.insert(I);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value *rewriteVectorizedLoadInst(IRBuilder<> &IRB, LoadInst &LI, Value *OldOp) {
|
Value *extractVector(IRBuilder<> &IRB,
|
||||||
Value *V = IRB.CreateAlignedLoad(&NewAI, NewAI.getAlignment(),
|
unsigned BeginIndex, unsigned EndIndex) {
|
||||||
getName(".load"));
|
|
||||||
unsigned BeginIndex = getIndex(BeginOffset);
|
|
||||||
unsigned EndIndex = getIndex(EndOffset);
|
|
||||||
assert(EndIndex > BeginIndex && "Empty vector!");
|
|
||||||
unsigned NumElements = EndIndex - BeginIndex;
|
unsigned NumElements = EndIndex - BeginIndex;
|
||||||
assert(NumElements <= VecTy->getNumElements() && "Too many elements!");
|
assert(NumElements <= VecTy->getNumElements() && "Too many elements!");
|
||||||
|
|
||||||
|
Value *V = IRB.CreateAlignedLoad(&NewAI, NewAI.getAlignment(),
|
||||||
|
getName(".load"));
|
||||||
|
|
||||||
|
if (NumElements == VecTy->getNumElements())
|
||||||
|
return V;
|
||||||
|
|
||||||
if (NumElements == 1) {
|
if (NumElements == 1) {
|
||||||
V = IRB.CreateExtractElement(V, IRB.getInt32(BeginIndex),
|
V = IRB.CreateExtractElement(V, IRB.getInt32(BeginIndex),
|
||||||
getName(".extract"));
|
getName(".extract"));
|
||||||
DEBUG(dbgs() << " extract: " << *V << "\n");
|
DEBUG(dbgs() << " extract: " << *V << "\n");
|
||||||
} else if (NumElements < VecTy->getNumElements()) {
|
return V;
|
||||||
|
}
|
||||||
|
|
||||||
SmallVector<Constant*, 8> Mask;
|
SmallVector<Constant*, 8> Mask;
|
||||||
Mask.reserve(NumElements);
|
Mask.reserve(NumElements);
|
||||||
for (unsigned i = BeginIndex; i != EndIndex; ++i)
|
for (unsigned i = BeginIndex; i != EndIndex; ++i)
|
||||||
|
@ -2409,10 +2414,16 @@ private:
|
||||||
ConstantVector::get(Mask),
|
ConstantVector::get(Mask),
|
||||||
getName(".extract"));
|
getName(".extract"));
|
||||||
DEBUG(dbgs() << " shuffle: " << *V << "\n");
|
DEBUG(dbgs() << " shuffle: " << *V << "\n");
|
||||||
}
|
|
||||||
return V;
|
return V;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Value *rewriteVectorizedLoadInst(IRBuilder<> &IRB) {
|
||||||
|
unsigned BeginIndex = getIndex(BeginOffset);
|
||||||
|
unsigned EndIndex = getIndex(EndOffset);
|
||||||
|
assert(EndIndex > BeginIndex && "Empty vector!");
|
||||||
|
return extractVector(IRB, BeginIndex, EndIndex);
|
||||||
|
}
|
||||||
|
|
||||||
Value *rewriteIntegerLoad(IRBuilder<> &IRB, LoadInst &LI) {
|
Value *rewriteIntegerLoad(IRBuilder<> &IRB, LoadInst &LI) {
|
||||||
assert(IntTy && "We cannot insert an integer to the alloca");
|
assert(IntTy && "We cannot insert an integer to the alloca");
|
||||||
assert(!LI.isVolatile());
|
assert(!LI.isVolatile());
|
||||||
|
@ -2457,7 +2468,7 @@ private:
|
||||||
bool IsPtrAdjusted = false;
|
bool IsPtrAdjusted = false;
|
||||||
Value *V;
|
Value *V;
|
||||||
if (VecTy) {
|
if (VecTy) {
|
||||||
V = rewriteVectorizedLoadInst(IRB, LI, OldOp);
|
V = rewriteVectorizedLoadInst(IRB);
|
||||||
} else if (IntTy && LI.getType()->isIntegerTy()) {
|
} else if (IntTy && LI.getType()->isIntegerTy()) {
|
||||||
V = rewriteIntegerLoad(IRB, LI);
|
V = rewriteIntegerLoad(IRB, LI);
|
||||||
} else if (BeginOffset == NewAllocaBeginOffset &&
|
} else if (BeginOffset == NewAllocaBeginOffset &&
|
||||||
|
|
Loading…
Reference in New Issue