diff options
author | Chris Lattner <sabre@nondot.org> | 2011-01-08 21:19:19 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-01-08 21:19:19 +0000 |
commit | d90a192279c8580c4e80d1ee102d1317ce2aaffa (patch) | |
tree | 164ef7aa26f4beef9bc64e8f7c5adb4d217b1c92 /test/Transforms | |
parent | 9fa11e94b5a7709cf05396420b3b3eaad6fb8e37 (diff) | |
download | external_llvm-d90a192279c8580c4e80d1ee102d1317ce2aaffa.zip external_llvm-d90a192279c8580c4e80d1ee102d1317ce2aaffa.tar.gz external_llvm-d90a192279c8580c4e80d1ee102d1317ce2aaffa.tar.bz2 |
Merge memsets followed by neighboring memsets and other stores into
larger memsets. Among other things, this fixes rdar://8760394 and
allows us to handle "Example 2" from http://blog.regehr.org/archives/320,
compiling it into a single 4096-byte memset:
_mad_synth_mute: ## @mad_synth_mute
## BB#0: ## %entry
pushq %rax
movl $4096, %esi ## imm = 0x1000
callq ___bzero
popq %rax
ret
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123089 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
-rw-r--r-- | test/Transforms/MemCpyOpt/form-memset.ll | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/Transforms/MemCpyOpt/form-memset.ll b/test/Transforms/MemCpyOpt/form-memset.ll index 523615d..1ac97e9 100644 --- a/test/Transforms/MemCpyOpt/form-memset.ll +++ b/test/Transforms/MemCpyOpt/form-memset.ll @@ -164,6 +164,7 @@ entry: declare void @foo(%struct.MV*, %struct.MV*, i8*) +; Store followed by memset. define void @test3(i32* nocapture %P) nounwind ssp { entry: %arrayidx = getelementptr inbounds i32* %P, i64 1 @@ -177,6 +178,7 @@ entry: ; CHECK: call void @llvm.memset.p0i8.i64(i8* %1, i8 0, i64 15, i32 4, i1 false) } +; store followed by memset, different offset scenario define void @test4(i32* nocapture %P) nounwind ssp { entry: store i32 0, i32* %P, align 4 @@ -191,4 +193,30 @@ entry: declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) nounwind +; Memset followed by store. +define void @test5(i32* nocapture %P) nounwind ssp { +entry: + %add.ptr = getelementptr inbounds i32* %P, i64 2 + %0 = bitcast i32* %add.ptr to i8* + tail call void @llvm.memset.p0i8.i64(i8* %0, i8 0, i64 11, i32 1, i1 false) + %arrayidx = getelementptr inbounds i32* %P, i64 1 + store i32 0, i32* %arrayidx, align 4 + ret void +; CHECK: @test5 +; CHECK-NOT: store +; CHECK: call void @llvm.memset.p0i8.i64(i8* %1, i8 0, i64 15, i32 4, i1 false) +} + +;; Memset followed by memset. +define void @test6(i32* nocapture %P) nounwind ssp { +entry: + %0 = bitcast i32* %P to i8* + tail call void @llvm.memset.p0i8.i64(i8* %0, i8 0, i64 12, i32 1, i1 false) + %add.ptr = getelementptr inbounds i32* %P, i64 3 + %1 = bitcast i32* %add.ptr to i8* + tail call void @llvm.memset.p0i8.i64(i8* %1, i8 0, i64 12, i32 1, i1 false) + ret void +; CHECK: @test6 +; CHECK: call void @llvm.memset.p0i8.i64(i8* %2, i8 0, i64 24, i32 1, i1 false) +} |