mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Use inbounds GEPs for memcpy and memset lowering
Follow-up on discussion in http://reviews.llvm.org/D11220 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242542 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f82375c972
commit
27bd1ca0d9
@ -87,13 +87,14 @@ void convertMemCpyToLoop(Instruction *ConvertedInst, Value *SrcAddr,
|
|||||||
// load from SrcAddr+LoopIndex
|
// load from SrcAddr+LoopIndex
|
||||||
// TODO: we can leverage the align parameter of llvm.memcpy for more efficient
|
// TODO: we can leverage the align parameter of llvm.memcpy for more efficient
|
||||||
// word-sized loads and stores.
|
// word-sized loads and stores.
|
||||||
Value *Element = LoopBuilder.CreateLoad(
|
Value *Element =
|
||||||
LoopBuilder.CreateGEP(LoopBuilder.getInt8Ty(), SrcAddr, LoopIndex),
|
LoopBuilder.CreateLoad(LoopBuilder.CreateInBoundsGEP(
|
||||||
|
LoopBuilder.getInt8Ty(), SrcAddr, LoopIndex),
|
||||||
SrcIsVolatile);
|
SrcIsVolatile);
|
||||||
// store at DstAddr+LoopIndex
|
// store at DstAddr+LoopIndex
|
||||||
LoopBuilder.CreateStore(
|
LoopBuilder.CreateStore(Element,
|
||||||
Element,
|
LoopBuilder.CreateInBoundsGEP(LoopBuilder.getInt8Ty(),
|
||||||
LoopBuilder.CreateGEP(LoopBuilder.getInt8Ty(), DstAddr, LoopIndex),
|
DstAddr, LoopIndex),
|
||||||
DstIsVolatile);
|
DstIsVolatile);
|
||||||
|
|
||||||
// The value for LoopIndex coming from backedge is (LoopIndex + 1)
|
// The value for LoopIndex coming from backedge is (LoopIndex + 1)
|
||||||
@ -225,7 +226,8 @@ void convertMemSetToLoop(Instruction *ConvertedInst, Value *DstAddr,
|
|||||||
LoopIndex->addIncoming(ConstantInt::get(CopyLen->getType(), 0), OrigBB);
|
LoopIndex->addIncoming(ConstantInt::get(CopyLen->getType(), 0), OrigBB);
|
||||||
|
|
||||||
LoopBuilder.CreateStore(
|
LoopBuilder.CreateStore(
|
||||||
SetValue, LoopBuilder.CreateGEP(SetValue->getType(), DstAddr, LoopIndex),
|
SetValue,
|
||||||
|
LoopBuilder.CreateInBoundsGEP(SetValue->getType(), DstAddr, LoopIndex),
|
||||||
false);
|
false);
|
||||||
|
|
||||||
Value *NewIndex =
|
Value *NewIndex =
|
||||||
|
@ -18,9 +18,9 @@ entry:
|
|||||||
|
|
||||||
; IR-LABEL: @memcpy_caller
|
; IR-LABEL: @memcpy_caller
|
||||||
; IR: loadstoreloop:
|
; IR: loadstoreloop:
|
||||||
; IR: [[LOADPTR:%[0-9]+]] = getelementptr i8, i8* %src, i64
|
; IR: [[LOADPTR:%[0-9]+]] = getelementptr inbounds i8, i8* %src, i64
|
||||||
; IR-NEXT: [[VAL:%[0-9]+]] = load i8, i8* [[LOADPTR]]
|
; IR-NEXT: [[VAL:%[0-9]+]] = load i8, i8* [[LOADPTR]]
|
||||||
; IR-NEXT: [[STOREPTR:%[0-9]+]] = getelementptr i8, i8* %dst, i64
|
; IR-NEXT: [[STOREPTR:%[0-9]+]] = getelementptr inbounds i8, i8* %dst, i64
|
||||||
; IR-NEXT: store i8 [[VAL]], i8* [[STOREPTR]]
|
; IR-NEXT: store i8 [[VAL]], i8* [[STOREPTR]]
|
||||||
|
|
||||||
; PTX-LABEL: .visible .func (.param .b64 func_retval0) memcpy_caller
|
; PTX-LABEL: .visible .func (.param .b64 func_retval0) memcpy_caller
|
||||||
@ -61,8 +61,8 @@ entry:
|
|||||||
; IR-LABEL: @memcpy_casting_caller
|
; IR-LABEL: @memcpy_casting_caller
|
||||||
; IR: [[DSTCAST:%[0-9]+]] = bitcast i32* %dst to i8*
|
; IR: [[DSTCAST:%[0-9]+]] = bitcast i32* %dst to i8*
|
||||||
; IR: [[SRCCAST:%[0-9]+]] = bitcast i32* %src to i8*
|
; IR: [[SRCCAST:%[0-9]+]] = bitcast i32* %src to i8*
|
||||||
; IR: getelementptr i8, i8* [[SRCCAST]]
|
; IR: getelementptr inbounds i8, i8* [[SRCCAST]]
|
||||||
; IR: getelementptr i8, i8* [[DSTCAST]]
|
; IR: getelementptr inbounds i8, i8* [[DSTCAST]]
|
||||||
}
|
}
|
||||||
|
|
||||||
define i8* @memset_caller(i8* %dst, i32 %c, i64 %n) #0 {
|
define i8* @memset_caller(i8* %dst, i32 %c, i64 %n) #0 {
|
||||||
@ -74,7 +74,7 @@ entry:
|
|||||||
; IR-LABEL: @memset_caller
|
; IR-LABEL: @memset_caller
|
||||||
; IR: [[VAL:%[0-9]+]] = trunc i32 %c to i8
|
; IR: [[VAL:%[0-9]+]] = trunc i32 %c to i8
|
||||||
; IR: loadstoreloop:
|
; IR: loadstoreloop:
|
||||||
; IR: [[STOREPTR:%[0-9]+]] = getelementptr i8, i8* %dst, i64
|
; IR: [[STOREPTR:%[0-9]+]] = getelementptr inbounds i8, i8* %dst, i64
|
||||||
; IR-NEXT: store i8 [[VAL]], i8* [[STOREPTR]]
|
; IR-NEXT: store i8 [[VAL]], i8* [[STOREPTR]]
|
||||||
|
|
||||||
; PTX-LABEL: .visible .func (.param .b64 func_retval0) memset_caller(
|
; PTX-LABEL: .visible .func (.param .b64 func_retval0) memset_caller(
|
||||||
|
Loading…
Reference in New Issue
Block a user