diff options
| author | Philip Reames <listmail@philipreames.com> | 2015-12-17 18:50:50 +0000 |
|---|---|---|
| committer | Philip Reames <listmail@philipreames.com> | 2015-12-17 18:50:50 +0000 |
| commit | 15145fb7b17d0499a706f8bb830dad272a06937d (patch) | |
| tree | c9c45a31defa100b23fa82b04aaa58ae58cfd3d9 /llvm/test/Transforms | |
| parent | 42c1e2923664d298970be6b0f8b21790859499e9 (diff) | |
| download | bcm5719-llvm-15145fb7b17d0499a706f8bb830dad272a06937d.tar.gz bcm5719-llvm-15145fb7b17d0499a706f8bb830dad272a06937d.zip | |
[EarlyCSE] DSE of atomic unordered stores
The rules for removing trivially dead stores are a lot less complicated than loads. Since we know the later store post dominates the former and the former dominates the later, unless the former has side effects other than the actual store, we can remove it. One slightly surprising thing is that we can freely remove atomic stores, even if the later one isn't atomic. There's no guarantee the atomic one was every visible.
For the moment, we don't handle DSE of ordered atomic stores. We could extend the same chain of reasoning to them, but the catch is we'd then have to model the ordering effect without a store instruction. Since our fences are a stronger than our operation orderings, simple using a fence isn't an obvious win. This arguable calls for a refinement in our fence specification, but that's (much) later work.
Differential Revision: http://reviews.llvm.org/D15352
llvm-svn: 255914
Diffstat (limited to 'llvm/test/Transforms')
| -rw-r--r-- | llvm/test/Transforms/EarlyCSE/atomics.ll | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/llvm/test/Transforms/EarlyCSE/atomics.ll b/llvm/test/Transforms/EarlyCSE/atomics.ll index ea85a86fa91..21c19cd8e88 100644 --- a/llvm/test/Transforms/EarlyCSE/atomics.ll +++ b/llvm/test/Transforms/EarlyCSE/atomics.ll @@ -181,5 +181,79 @@ define void @test22(i1 %B, i32* %P1, i32* %P2) { ret void } +; Can also DSE a unordered store in favor of a normal one +define void @test23(i1 %B, i32* %P1, i32* %P2) { +; CHECK-LABEL: @test23 +; CHECK-NEXT: store i32 0 + store atomic i32 3, i32* %P1 unordered, align 4 + store i32 0, i32* %P1, align 4 + ret void +} + +; As an implementation limitation, can't remove ordered stores +; Note that we could remove the earlier store if we could +; represent the required ordering. +define void @test24(i1 %B, i32* %P1, i32* %P2) { +; CHECK-LABEL: @test24 +; CHECK-NEXT: store atomic +; CHECK-NEXT: store i32 0 + store atomic i32 3, i32* %P1 release, align 4 + store i32 0, i32* %P1, align 4 + ret void +} +; Can't remove volatile stores - each is independently observable and +; the count of such stores is an observable program side effect. +define void @test25(i1 %B, i32* %P1, i32* %P2) { +; CHECK-LABEL: @test25 +; CHECK-NEXT: store volatile +; CHECK-NEXT: store volatile + store volatile i32 3, i32* %P1, align 4 + store volatile i32 0, i32* %P1, align 4 + ret void +} +; Can DSE a unordered store in favor of a unordered one +define void @test26(i1 %B, i32* %P1, i32* %P2) { +; CHECK-LABEL: @test26 +; CHECK-NEXT: store atomic i32 3, i32* %P1 unordered, align 4 +; CHECK-NEXT: ret + store atomic i32 0, i32* %P1 unordered, align 4 + store atomic i32 3, i32* %P1 unordered, align 4 + ret void +} + +; Can DSE a unordered store in favor of a ordered one, +; but current don't due to implementation limits +define void @test27(i1 %B, i32* %P1, i32* %P2) { +; CHECK-LABEL: @test27 +; CHECK-NEXT: store atomic i32 0, i32* %P1 unordered, align 4 +; CHECK-NEXT: store atomic i32 3, i32* %P1 release, align 4 +; CHECK-NEXT: ret + store atomic i32 0, i32* %P1 unordered, align 4 + store atomic i32 3, i32* %P1 release, align 4 + ret void +} + +; Can DSE an unordered atomic store in favor of an +; ordered one, but current don't due to implementation limits +define void @test28(i1 %B, i32* %P1, i32* %P2) { +; CHECK-LABEL: @test28 +; CHECK-NEXT: store atomic i32 0, i32* %P1 unordered, align 4 +; CHECK-NEXT: store atomic i32 3, i32* %P1 release, align 4 +; CHECK-NEXT: ret + store atomic i32 0, i32* %P1 unordered, align 4 + store atomic i32 3, i32* %P1 release, align 4 + ret void +} + +; As an implementation limitation, can't remove ordered stores +; see also: @test24 +define void @test29(i1 %B, i32* %P1, i32* %P2) { +; CHECK-LABEL: @test29 +; CHECK-NEXT: store atomic +; CHECK-NEXT: store atomic + store atomic i32 3, i32* %P1 release, align 4 + store atomic i32 0, i32* %P1 unordered, align 4 + ret void +} |

