mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-13 09:33:50 +00:00
MemCpyOpt: When forming a memset from stores also take GEP constexprs into account.
This is common when storing to global variables. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163809 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
aa8405811e
commit
39acdb0200
@ -38,7 +38,7 @@ STATISTIC(NumMemSetInfer, "Number of memsets inferred");
|
||||
STATISTIC(NumMoveToCpy, "Number of memmoves converted to memcpy");
|
||||
STATISTIC(NumCpyToSet, "Number of memcpys converted to memset");
|
||||
|
||||
static int64_t GetOffsetFromIndex(const GetElementPtrInst *GEP, unsigned Idx,
|
||||
static int64_t GetOffsetFromIndex(const GEPOperator *GEP, unsigned Idx,
|
||||
bool &VariableIdxFound, const TargetData &TD){
|
||||
// Skip over the first indices.
|
||||
gep_type_iterator GTI = gep_type_begin(GEP);
|
||||
@ -75,8 +75,8 @@ static bool IsPointerOffset(Value *Ptr1, Value *Ptr2, int64_t &Offset,
|
||||
const TargetData &TD) {
|
||||
Ptr1 = Ptr1->stripPointerCasts();
|
||||
Ptr2 = Ptr2->stripPointerCasts();
|
||||
GetElementPtrInst *GEP1 = dyn_cast<GetElementPtrInst>(Ptr1);
|
||||
GetElementPtrInst *GEP2 = dyn_cast<GetElementPtrInst>(Ptr2);
|
||||
GEPOperator *GEP1 = dyn_cast<GEPOperator>(Ptr1);
|
||||
GEPOperator *GEP2 = dyn_cast<GEPOperator>(Ptr2);
|
||||
|
||||
bool VariableIdxFound = false;
|
||||
|
||||
|
@ -248,3 +248,27 @@ entry:
|
||||
; CHECK: @test8
|
||||
; CHECK: store <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, <4 x i32>* %0, align 16
|
||||
}
|
||||
|
||||
@test9buf = internal unnamed_addr global [16 x i64] zeroinitializer, align 16
|
||||
|
||||
define void @test9() nounwind {
|
||||
store i8 -1, i8* bitcast ([16 x i64]* @test9buf to i8*), align 16
|
||||
store i8 -1, i8* getelementptr (i8* bitcast ([16 x i64]* @test9buf to i8*), i64 1), align 1
|
||||
store i8 -1, i8* getelementptr (i8* bitcast ([16 x i64]* @test9buf to i8*), i64 2), align 2
|
||||
store i8 -1, i8* getelementptr (i8* bitcast ([16 x i64]* @test9buf to i8*), i64 3), align 1
|
||||
store i8 -1, i8* getelementptr (i8* bitcast ([16 x i64]* @test9buf to i8*), i64 4), align 4
|
||||
store i8 -1, i8* getelementptr (i8* bitcast ([16 x i64]* @test9buf to i8*), i64 5), align 1
|
||||
store i8 -1, i8* getelementptr (i8* bitcast ([16 x i64]* @test9buf to i8*), i64 6), align 2
|
||||
store i8 -1, i8* getelementptr (i8* bitcast ([16 x i64]* @test9buf to i8*), i64 7), align 1
|
||||
store i8 -1, i8* bitcast (i64* getelementptr inbounds ([16 x i64]* @test9buf, i64 0, i64 1) to i8*), align 8
|
||||
store i8 -1, i8* getelementptr (i8* bitcast ([16 x i64]* @test9buf to i8*), i64 9), align 1
|
||||
store i8 -1, i8* getelementptr (i8* bitcast ([16 x i64]* @test9buf to i8*), i64 10), align 2
|
||||
store i8 -1, i8* getelementptr (i8* bitcast ([16 x i64]* @test9buf to i8*), i64 11), align 1
|
||||
store i8 -1, i8* getelementptr (i8* bitcast ([16 x i64]* @test9buf to i8*), i64 12), align 4
|
||||
store i8 -1, i8* getelementptr (i8* bitcast ([16 x i64]* @test9buf to i8*), i64 13), align 1
|
||||
store i8 -1, i8* getelementptr (i8* bitcast ([16 x i64]* @test9buf to i8*), i64 14), align 2
|
||||
store i8 -1, i8* getelementptr (i8* bitcast ([16 x i64]* @test9buf to i8*), i64 15), align 1
|
||||
ret void
|
||||
; CHECK: @test9(
|
||||
; CHECK: call void @llvm.memset.p0i8.i64(i8* bitcast ([16 x i64]* @test9buf to i8*), i8 -1, i64 16, i32 16, i1 false)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user