[PATCH] D87386: [DSE,MemorySSA] Handle atomic stores expliclty in isReadClobber.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 9 15:02:22 PDT 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9969c317ff08: [DSE,MemorySSA] Handle atomic stores explicitly in isReadClobber. (authored by fhahn).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87386/new/
https://reviews.llvm.org/D87386
Files:
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
llvm/test/Transforms/DeadStoreElimination/MSSA/atomic-todo.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/atomic.ll
Index: llvm/test/Transforms/DeadStoreElimination/MSSA/atomic.ll
===================================================================
--- llvm/test/Transforms/DeadStoreElimination/MSSA/atomic.ll
+++ llvm/test/Transforms/DeadStoreElimination/MSSA/atomic.ll
@@ -88,6 +88,17 @@
ret i32 %x
}
+; DSE across monotonic store (allowed as long as the eliminated store isUnordered)
+define void @test10() {
+; CHECK-LABEL: test10
+; CHECK-NOT: store i32 0
+; CHECK: store i32 1
+ store i32 0, i32* @x
+ store atomic i32 42, i32* @y monotonic, align 4
+ store i32 1, i32* @x
+ ret void
+}
+
; DSE across monotonic load (forbidden since the eliminated store is atomic)
define i32 @test11() {
; CHECK-LABEL: @test11(
Index: llvm/test/Transforms/DeadStoreElimination/MSSA/atomic-todo.ll
===================================================================
--- llvm/test/Transforms/DeadStoreElimination/MSSA/atomic-todo.ll
+++ llvm/test/Transforms/DeadStoreElimination/MSSA/atomic-todo.ll
@@ -21,14 +21,3 @@
store i32 1, i32* @x
ret i32 %x
}
-
-; DSE across monotonic store (allowed as long as the eliminated store isUnordered)
-define void @test10() {
-; CHECK-LABEL: test10
-; CHECK-NOT: store i32 0
-; CHECK: store i32 1
- store i32 0, i32* @x
- store atomic i32 42, i32* @y monotonic, align 4
- store i32 1, i32* @x
- ret void
-}
Index: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1824,6 +1824,11 @@
// Returns true if \p Use may read from \p DefLoc.
bool isReadClobber(MemoryLocation DefLoc, Instruction *UseInst) {
+ // Monotonic or weaker atomic stores can be re-ordered and do not need to be
+ // treated as read clobber.
+ if (auto SI = dyn_cast<StoreInst>(UseInst))
+ return isStrongerThan(SI->getOrdering(), AtomicOrdering::Monotonic);
+
if (!UseInst->mayReadFromMemory())
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87386.290831.patch
Type: text/x-patch
Size: 2032 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200909/50732dce/attachment.bin>
More information about the llvm-commits
mailing list