2003-08-05 18:52:42 +00:00
|
|
|
; This testcase tests to make sure a trapping instruction is hoisted when
|
|
|
|
; it is guaranteed to execute.
|
|
|
|
;
|
2008-03-19 03:47:13 +00:00
|
|
|
; RUN: llvm-as < %s | opt -licm | llvm-dis | %prcontext "test" 2 | grep div
|
2003-08-05 18:52:42 +00:00
|
|
|
|
2008-03-19 03:47:13 +00:00
|
|
|
@X = global i32 0 ; <i32*> [#uses=1]
|
2003-08-05 18:52:42 +00:00
|
|
|
|
2008-03-19 03:47:13 +00:00
|
|
|
declare void @foo(i32)
|
2003-08-05 18:52:42 +00:00
|
|
|
|
2008-03-19 03:47:13 +00:00
|
|
|
define i32 @test(i1 %c) {
|
|
|
|
%A = load i32* @X ; <i32> [#uses=2]
|
|
|
|
br label %Loop
|
|
|
|
Loop: ; preds = %Loop, %0
|
|
|
|
;; Should have hoisted this div!
|
|
|
|
%B = sdiv i32 4, %A ; <i32> [#uses=2]
|
|
|
|
call void @foo( i32 %B )
|
|
|
|
br i1 %c, label %Loop, label %Out
|
|
|
|
Out: ; preds = %Loop
|
|
|
|
%C = sub i32 %A, %B ; <i32> [#uses=1]
|
|
|
|
ret i32 %C
|
2003-08-05 18:52:42 +00:00
|
|
|
}
|