]> granicus.if.org Git - llvm/commitdiff
Merging r228760 and r228761:
authorHans Wennborg <hans@hanshq.net>
Wed, 11 Feb 2015 02:23:00 +0000 (02:23 +0000)
committerHans Wennborg <hans@hanshq.net>
Wed, 11 Feb 2015 02:23:00 +0000 (02:23 +0000)
------------------------------------------------------------------------
r228760 | majnemer | 2015-02-10 15:09:43 -0800 (Tue, 10 Feb 2015) | 3 lines

EarlyCSE: It isn't safe to CSE across synchronization boundaries

This fixes PR22514.
------------------------------------------------------------------------

------------------------------------------------------------------------
r228761 | majnemer | 2015-02-10 15:11:02 -0800 (Tue, 10 Feb 2015) | 1 line

EarlyCSE: Add check lines for test added in r228760
------------------------------------------------------------------------

git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_36@228790 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/EarlyCSE.cpp
test/Transforms/EarlyCSE/basic.ll

index 394b0d3de7bdc12719051bf8c22386a9276fcebc..969b9a8f8df1d87a78ac76ff69892de0e1860e3b 100644 (file)
@@ -480,6 +480,9 @@ bool EarlyCSE::processNode(DomTreeNode *Node) {
       // Ignore volatile loads.
       if (!LI->isSimple()) {
         LastStore = nullptr;
+        // Don't CSE across synchronization boundaries.
+        if (Inst->mayWriteToMemory())
+          ++CurrentGeneration;
         continue;
       }
 
index 155d36f60e2100a12fc8d7d2f3727e7f3d7af9ac..3ec8831def181d45c5424f4a8ef6937f5c661e4c 100644 (file)
@@ -192,4 +192,13 @@ define void @test11(i32 *%P) {
   ; CHECK-NEXT: ret void
 }
 
-
+; CHECK-LABEL: @test12(
+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
+  ; CHECK: load i32* %P1
+  ; CHECK: load i32* %P1
+}