[LICM] Add tests from D50786 [NFC]
authorPhilip Reames <listmail@philipreames.com>
Tue, 21 Aug 2018 00:42:07 +0000 (00:42 +0000)
committerPhilip Reames <listmail@philipreames.com>
Tue, 21 Aug 2018 00:42:07 +0000 (00:42 +0000)
Exercise more use of volatiles to illustrate that nothing changes as we tweak how we detect them.

llvm-svn: 340244

llvm/test/Transforms/LICM/hoisting.ll
llvm/test/Transforms/LICM/scalar-promote.ll

index cbd1768..4572ad3 100644 (file)
@@ -150,6 +150,23 @@ return:
   ret i32 %sum
 }
 
+; Can neither sink nor hoist
+define i32 @test_volatile(i1 %c) {
+; CHECK-LABEL: @test_volatile(
+; CHECK-LABEL: Loop:
+; CHECK: load volatile i32, i32* @X
+; CHECK-LABEL: Out:
+  br label %Loop
+
+Loop:
+  %A = load volatile i32, i32* @X
+  br i1 %c, label %Loop, label %Out
+
+Out:
+  ret i32 %A
+}
+
+
 declare {}* @llvm.invariant.start.p0i8(i64, i8* nocapture) nounwind readonly
 declare void @llvm.invariant.end.p0i8({}*, i64, i8* nocapture) nounwind
 declare void @escaping.invariant.start({}*) nounwind
index ef91020..b719c1e 100644 (file)
@@ -74,6 +74,23 @@ Out:    ; preds = %Loop
   ret void
 }
 
+define void @test3b(i32 %i) {
+; CHECK-LABEL: @test3b(
+; CHECK-LABEL: Loop:
+; CHECK: store volatile
+; CHECK-LABEL: Out:
+  br label %Loop
+Loop:
+        ; Should not promote this to a register
+  %x = load i32, i32* @X
+  %x2 = add i32 %x, 1
+  store volatile i32 %x2, i32* @X
+  br i1 true, label %Out, label %Loop
+
+Out:    ; preds = %Loop
+  ret void
+}
+
 ; PR8041
 define void @test4(i8* %x, i8 %n) {
 ; CHECK-LABEL: @test4(