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
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(