fix PR8677, patch by Jakub Staszak!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120325 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-11-29 21:59:31 +00:00
parent 7bb5996e47
commit e9e973018a
2 changed files with 18 additions and 2 deletions

View File

@ -235,8 +235,10 @@ bool DSE::runOnBasicBlock(BasicBlock &BB) {
&BB);
}
// If not a definite must-alias dependency, ignore it.
if (!InstDep.isDef())
// If not a definite must-alias store dependency, ignore it. If this is a
// load from the same pointer, we don't want to transform load+store into
// a noop.
if (!InstDep.isDef() || !isa<StoreInst>(InstDep.getInst()))
continue;
}

View File

@ -20,3 +20,17 @@ define void @test2(i32 *%p, i32 *%q) {
; CHECK: @test2
; CHECK-NEXT: store i32 20
}
; PR8677
@g = global i32 1
define i32 @test3(i32* %g_addr) nounwind {
; CHECK: @test3
; CHEcK: load i32* %g_addr
%g_value = load i32* %g_addr, align 4
store i32 -1, i32* @g, align 4
store i32 %g_value, i32* %g_addr, align 4
%tmp3 = load i32* @g, align 4
ret i32 %tmp3
}