HomePhabricator

[DeadStoreElimination] remove a redundant store even if the load is in a…

Authored by eeckstein on Aug 13 2015, 8:36 AM.

Description

[DeadStoreElimination] remove a redundant store even if the load is in a different block.

DeadStoreElimination does eliminate a store if it stores a value which was loaded from the same memory location.
So far this worked only if the store is in the same block as the load.
Now we can also handle stores which are in a different block than the load.
Example:

define i32 @test(i1, i32*) {
entry:

%l2 = load i32, i32* %1, align 4
br i1 %0, label %bb1, label %bb2

bb1:

br label %bb3

bb2:

; This store is redundant
store i32 %l2, i32* %1, align 4
br label %bb3

bb3:

ret i32 0

}

Differential Revision: http://reviews.llvm.org/D11854

llvm-svn: 244901