diff options
author | Chris Lattner <sabre@nondot.org> | 2011-04-26 01:21:15 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-04-26 01:21:15 +0000 |
commit | 6f83d06ffa19e4321cb603188e1b922bc5c7196c (patch) | |
tree | d5072c030e17e899b00cc1b63c4011dcaa27cecd /llvm/test | |
parent | 6f095d613a406b64465b918d2cc47fe3e13ad8b8 (diff) | |
download | bcm5719-llvm-6f83d06ffa19e4321cb603188e1b922bc5c7196c.tar.gz bcm5719-llvm-6f83d06ffa19e4321cb603188e1b922bc5c7196c.zip |
Enhance MemDep: When alias analysis returns a partial alias result,
return it as a clobber. This allows GVN to do smart things.
Enhance GVN to be smart about the case when a small load is clobbered
by a larger overlapping load. In this case, forward the value. This
allows us to compile stuff like this:
int test(void *P) {
int tmp = *(unsigned int*)P;
return tmp+*((unsigned char*)P+1);
}
into:
_test: ## @test
movl (%rdi), %ecx
movzbl %ch, %eax
addl %ecx, %eax
ret
which has one load. We already handled the case where the smaller
load was from a must-aliased base pointer.
llvm-svn: 130180
Diffstat (limited to 'llvm/test')
-rw-r--r-- | llvm/test/Transforms/GVN/rle.ll | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/test/Transforms/GVN/rle.ll b/llvm/test/Transforms/GVN/rle.ll index 2e433217507..42363d8bb2b 100644 --- a/llvm/test/Transforms/GVN/rle.ll +++ b/llvm/test/Transforms/GVN/rle.ll @@ -544,3 +544,30 @@ entry: ; CHECK: ret i32 0 } + +;;===----------------------------------------------------------------------===;; +;; Load -> Load forwarding in partial alias case. +;;===----------------------------------------------------------------------===;; + +define i32 @load_load_partial_alias(i8* %P) nounwind ssp { +entry: + %0 = bitcast i8* %P to i32* + %tmp2 = load i32* %0 + %add.ptr = getelementptr inbounds i8* %P, i64 1 + %tmp5 = load i8* %add.ptr + %conv = zext i8 %tmp5 to i32 + %add = add nsw i32 %tmp2, %conv + ret i32 %add + +; CHECK: @load_load_partial_alias +; CHECK: load i32* +; CHECK-NOT: load +; CHECK: lshr i32 {{.*}}, 8 +; CHECK-NOT: load +; CHECK: trunc i32 {{.*}} to i8 +; CHECK-NOT: load +; CHECK: ret i32 +} + + + |