; This testcase tests for a problem where LICM hoists
; potentially trapping instructions when they are not guaranteed to execute.
;
-; RUN: llvm-as < %s | opt -licm | llvm-dis | grep -C2 "IfUnEqual" | grep div
+; RUN: llvm-as < %s | opt -licm | llvm-dis | %prcontext "IfUnEqual" 2 | grep div
-%X = global int 0
-declare void %foo()
+@X = global i32 0 ; <i32*> [#uses=1]
-int %test(bool %c) {
- %A = load int *%X
- br label %Loop
-Loop:
- call void %foo()
- br bool %c, label %LoopTail, label %IfUnEqual
+declare void @foo()
-IfUnEqual:
- %B1 = div int 4, %A ;; Should not hoist this div!
+define i32 @test(i1 %c) {
+ %A = load i32* @X ; <i32> [#uses=2]
+ br label %Loop
+Loop: ; preds = %LoopTail, %0
+ call void @foo( )
+ br i1 %c, label %LoopTail, label %IfUnEqual
+IfUnEqual: ; preds = %Loop
+ %B1 = sdiv i32 4, %A ; <i32> [#uses=1]
br label %LoopTail
-
-LoopTail:
- %B = phi int [ 0, %Loop ], [ %B1, %IfUnEqual]
- br bool %c, label %Loop, label %Out
-
-Out:
- %C = sub int %A, %B
- ret int %C
+LoopTail: ; preds = %IfUnEqual, %Loop
+ %B = phi i32 [ 0, %Loop ], [ %B1, %IfUnEqual ] ; <i32> [#uses=1]
+ br i1 %c, label %Loop, label %Out
+Out: ; preds = %LoopTail
+ %C = sub i32 %A, %B ; <i32> [#uses=1]
+ ret i32 %C
}
+