mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-15 07:34:33 +00:00
Dest type is always i8 *. This allows some simplification.
Do not filter memmove. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42930 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
fff760296f
commit
7b9e1d251f
@ -7669,43 +7669,22 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
|
|||||||
// If MemCpyInst length is 1/2/4/8 bytes then replace memcpy with
|
// If MemCpyInst length is 1/2/4/8 bytes then replace memcpy with
|
||||||
// load/store.
|
// load/store.
|
||||||
ConstantInt *MemOpLength = dyn_cast<ConstantInt>(CI.getOperand(3));
|
ConstantInt *MemOpLength = dyn_cast<ConstantInt>(CI.getOperand(3));
|
||||||
if (isa<MemCpyInst>(MI))
|
if (MemOpLength) {
|
||||||
if (MemOpLength) {
|
|
||||||
unsigned Size = MemOpLength->getZExtValue();
|
unsigned Size = MemOpLength->getZExtValue();
|
||||||
unsigned Align = cast<ConstantInt>(CI.getOperand(4))->getZExtValue();
|
unsigned Align = cast<ConstantInt>(CI.getOperand(4))->getZExtValue();
|
||||||
const PointerType *PTy = cast<PointerType>(CI.getOperand(1)->getType());
|
|
||||||
const Type *MTy = PTy->getElementType();
|
|
||||||
PointerType *NewPtrTy = NULL;
|
PointerType *NewPtrTy = NULL;
|
||||||
if (MTy == Type::Int8Ty) {
|
// Destination pointer type is always i8 *
|
||||||
if (Size == 8)
|
if (Size == 8)
|
||||||
NewPtrTy = PointerType::get(Type::Int64Ty);
|
NewPtrTy = PointerType::get(Type::Int64Ty);
|
||||||
else if (Size == 4)
|
else if (Size == 4)
|
||||||
NewPtrTy = PointerType::get(Type::Int32Ty);
|
NewPtrTy = PointerType::get(Type::Int32Ty);
|
||||||
else if (Size == 2)
|
else if (Size == 2)
|
||||||
NewPtrTy = PointerType::get(Type::Int16Ty);
|
NewPtrTy = PointerType::get(Type::Int16Ty);
|
||||||
else if (Size == 1)
|
else if (Size == 1)
|
||||||
NewPtrTy = PointerType::get(Type::Int8Ty);
|
NewPtrTy = PointerType::get(Type::Int8Ty);
|
||||||
} else if (MTy == Type::Int16Ty) {
|
|
||||||
if (Size == 4)
|
|
||||||
NewPtrTy = PointerType::get(Type::Int64Ty);
|
|
||||||
else if (Size == 2)
|
|
||||||
NewPtrTy = PointerType::get(Type::Int32Ty);
|
|
||||||
else if (Size == 1)
|
|
||||||
NewPtrTy = PointerType::get(Type::Int16Ty);
|
|
||||||
} else if (MTy == Type::Int32Ty) {
|
|
||||||
if (Size == 2)
|
|
||||||
NewPtrTy = PointerType::get(Type::Int64Ty);
|
|
||||||
else if (Size == 1)
|
|
||||||
NewPtrTy = PointerType::get(Type::Int32Ty);
|
|
||||||
} else if (MTy == Type::Int64Ty) {
|
|
||||||
if (Size == 1)
|
|
||||||
NewPtrTy = PointerType::get(Type::Int64Ty);
|
|
||||||
}
|
|
||||||
if (NewPtrTy) {
|
if (NewPtrTy) {
|
||||||
Value *Src =
|
Value *Src = InsertCastBefore(Instruction::BitCast, CI.getOperand(2), NewPtrTy, CI);
|
||||||
InsertCastBefore(Instruction::BitCast,CI.getOperand(2),NewPtrTy,CI);
|
Value *Dest = InsertCastBefore(Instruction::BitCast, CI.getOperand(1), NewPtrTy, CI);
|
||||||
Value *Dest =
|
|
||||||
InsertCastBefore(Instruction::BitCast,CI.getOperand(1),NewPtrTy,CI);
|
|
||||||
Value *L = new LoadInst(Src, "tmp", false, Align, &CI);
|
Value *L = new LoadInst(Src, "tmp", false, Align, &CI);
|
||||||
Value *NS = new StoreInst(L, Dest, false, Align, &CI);
|
Value *NS = new StoreInst(L, Dest, false, Align, &CI);
|
||||||
CI.replaceAllUsesWith(NS);
|
CI.replaceAllUsesWith(NS);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user