2003-12-09 17:56:51 +01:00
|
|
|
; To reduce register pressure, if a load is hoistable out of the loop, and the
|
|
|
|
; result of the load is only used outside of the loop, sink the load instead of
|
|
|
|
; hoisting it!
|
|
|
|
;
|
2008-03-19 04:47:13 +01:00
|
|
|
; RUN: llvm-as < %s | opt -licm | llvm-dis | %prcontext load 1 | grep Out:
|
2003-12-09 17:56:51 +01:00
|
|
|
|
2008-03-19 04:47:13 +01:00
|
|
|
@X = global i32 5 ; <i32*> [#uses=1]
|
2003-12-09 17:56:51 +01:00
|
|
|
|
2008-03-19 04:47:13 +01:00
|
|
|
define i32 @test(i32 %N) {
|
2003-12-09 17:56:51 +01:00
|
|
|
Entry:
|
|
|
|
br label %Loop
|
2008-03-19 04:47:13 +01:00
|
|
|
Loop: ; preds = %Loop, %Entry
|
|
|
|
%N_addr.0.pn = phi i32 [ %dec, %Loop ], [ %N, %Entry ] ; <i32> [#uses=2]
|
|
|
|
%tmp.6 = load i32* @X ; <i32> [#uses=1]
|
|
|
|
%dec = add i32 %N_addr.0.pn, -1 ; <i32> [#uses=1]
|
|
|
|
%tmp.1 = icmp ne i32 %N_addr.0.pn, 1 ; <i1> [#uses=1]
|
|
|
|
br i1 %tmp.1, label %Loop, label %Out
|
|
|
|
Out: ; preds = %Loop
|
|
|
|
ret i32 %tmp.6
|
2003-12-09 17:56:51 +01:00
|
|
|
}
|
2008-03-19 04:47:13 +01:00
|
|
|
|