[llvm] r228760 - EarlyCSE: It isn't safe to CSE across synchronization boundaries
David Majnemer
david.majnemer at gmail.com
Tue Feb 10 15:09:43 PST 2015
Author: majnemer
Date: Tue Feb 10 17:09:43 2015
New Revision: 228760
URL: http://llvm.org/viewvc/llvm-project?rev=228760&view=rev
Log:
EarlyCSE: It isn't safe to CSE across synchronization boundaries
This fixes PR22514.
Modified:
llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp
llvm/trunk/test/Transforms/EarlyCSE/basic.ll
Modified: llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp?rev=228760&r1=228759&r2=228760&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/EarlyCSE.cpp Tue Feb 10 17:09:43 2015
@@ -527,6 +527,9 @@ bool EarlyCSE::processNode(DomTreeNode *
// Ignore volatile loads.
if (MemInst.isVolatile()) {
LastStore = nullptr;
+ // Don't CSE across synchronization boundaries.
+ if (Inst->mayWriteToMemory())
+ ++CurrentGeneration;
continue;
}
Modified: llvm/trunk/test/Transforms/EarlyCSE/basic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/EarlyCSE/basic.ll?rev=228760&r1=228759&r2=228760&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/EarlyCSE/basic.ll (original)
+++ llvm/trunk/test/Transforms/EarlyCSE/basic.ll Tue Feb 10 17:09:43 2015
@@ -193,4 +193,10 @@ define void @test11(i32 *%P) {
; CHECK-NEXT: ret void
}
-
+define i32 @test12(i1 %B, i32* %P1, i32* %P2) {
+ %load0 = load i32* %P1
+ %1 = load atomic i32* %P2 seq_cst, align 4
+ %load1 = load i32* %P1
+ %sel = select i1 %B, i32 %load0, i32 %load1
+ ret i32 %sel
+}
More information about the llvm-commits
mailing list