mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-25 00:29:20 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170324 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1ffe48a84b
commit
8ab1efd5fc
@ -2388,31 +2388,42 @@ private:
|
||||
Pass.DeadInsts.insert(I);
|
||||
}
|
||||
|
||||
Value *rewriteVectorizedLoadInst(IRBuilder<> &IRB, LoadInst &LI, Value *OldOp) {
|
||||
Value *V = IRB.CreateAlignedLoad(&NewAI, NewAI.getAlignment(),
|
||||
getName(".load"));
|
||||
unsigned BeginIndex = getIndex(BeginOffset);
|
||||
unsigned EndIndex = getIndex(EndOffset);
|
||||
assert(EndIndex > BeginIndex && "Empty vector!");
|
||||
Value *extractVector(IRBuilder<> &IRB,
|
||||
unsigned BeginIndex, unsigned EndIndex) {
|
||||
unsigned NumElements = EndIndex - BeginIndex;
|
||||
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) {
|
||||
V = IRB.CreateExtractElement(V, IRB.getInt32(BeginIndex),
|
||||
getName(".extract"));
|
||||
DEBUG(dbgs() << " extract: " << *V << "\n");
|
||||
} else if (NumElements < VecTy->getNumElements()) {
|
||||
SmallVector<Constant*, 8> Mask;
|
||||
Mask.reserve(NumElements);
|
||||
for (unsigned i = BeginIndex; i != EndIndex; ++i)
|
||||
Mask.push_back(IRB.getInt32(i));
|
||||
V = IRB.CreateShuffleVector(V, UndefValue::get(V->getType()),
|
||||
ConstantVector::get(Mask),
|
||||
getName(".extract"));
|
||||
DEBUG(dbgs() << " shuffle: " << *V << "\n");
|
||||
return V;
|
||||
}
|
||||
|
||||
SmallVector<Constant*, 8> Mask;
|
||||
Mask.reserve(NumElements);
|
||||
for (unsigned i = BeginIndex; i != EndIndex; ++i)
|
||||
Mask.push_back(IRB.getInt32(i));
|
||||
V = IRB.CreateShuffleVector(V, UndefValue::get(V->getType()),
|
||||
ConstantVector::get(Mask),
|
||||
getName(".extract"));
|
||||
DEBUG(dbgs() << " shuffle: " << *V << "\n");
|
||||
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) {
|
||||
assert(IntTy && "We cannot insert an integer to the alloca");
|
||||
assert(!LI.isVolatile());
|
||||
@ -2457,7 +2468,7 @@ private:
|
||||
bool IsPtrAdjusted = false;
|
||||
Value *V;
|
||||
if (VecTy) {
|
||||
V = rewriteVectorizedLoadInst(IRB, LI, OldOp);
|
||||
V = rewriteVectorizedLoadInst(IRB);
|
||||
} else if (IntTy && LI.getType()->isIntegerTy()) {
|
||||
V = rewriteIntegerLoad(IRB, LI);
|
||||
} else if (BeginOffset == NewAllocaBeginOffset &&
|
||||
|
Loading…
Reference in New Issue
Block a user