2009-10-27 06:50:28 +01:00
|
|
|
; RUN: llc < %s -march=arm | FileCheck %s
|
2007-04-03 02:13:16 +02:00
|
|
|
|
2010-02-12 11:34:29 +01:00
|
|
|
; This loop is rewritten with an indvar which counts down, which
|
|
|
|
; frees up a register from holding the trip count.
|
|
|
|
|
2009-05-18 17:16:49 +02:00
|
|
|
define void @test(i32* %P, i32 %A, i32 %i) nounwind {
|
2007-04-03 02:13:16 +02:00
|
|
|
entry:
|
2010-03-17 18:52:21 +01:00
|
|
|
; CHECK: str r1, [{{r.*}}, {{r.*}}, lsl #2]
|
2010-02-12 11:34:29 +01:00
|
|
|
icmp eq i32 %i, 0 ; <i1>:0 [#uses=1]
|
|
|
|
br i1 %0, label %return, label %bb
|
|
|
|
|
|
|
|
bb: ; preds = %bb, %entry
|
|
|
|
%indvar = phi i32 [ 0, %entry ], [ %indvar.next, %bb ] ; <i32> [#uses=2]
|
|
|
|
%i_addr.09.0 = sub i32 %i, %indvar ; <i32> [#uses=1]
|
|
|
|
%tmp2 = getelementptr i32* %P, i32 %i_addr.09.0 ; <i32*> [#uses=1]
|
|
|
|
store i32 %A, i32* %tmp2
|
|
|
|
%indvar.next = add i32 %indvar, 1 ; <i32> [#uses=2]
|
|
|
|
icmp eq i32 %indvar.next, %i ; <i1>:1 [#uses=1]
|
|
|
|
br i1 %1, label %return, label %bb
|
|
|
|
|
|
|
|
return: ; preds = %bb, %entry
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; This loop has a non-address use of the count-up indvar, so
|
|
|
|
; it'll remain. Now the original store uses a negative-stride address.
|
|
|
|
|
|
|
|
define void @test_with_forced_iv(i32* %P, i32 %A, i32 %i) nounwind {
|
|
|
|
entry:
|
2009-10-27 06:50:28 +01:00
|
|
|
; CHECK: str r1, [{{r.*}}, -{{r.*}}, lsl #2]
|
2007-04-03 02:13:16 +02:00
|
|
|
icmp eq i32 %i, 0 ; <i1>:0 [#uses=1]
|
|
|
|
br i1 %0, label %return, label %bb
|
|
|
|
|
|
|
|
bb: ; preds = %bb, %entry
|
|
|
|
%indvar = phi i32 [ 0, %entry ], [ %indvar.next, %bb ] ; <i32> [#uses=2]
|
|
|
|
%i_addr.09.0 = sub i32 %i, %indvar ; <i32> [#uses=1]
|
|
|
|
%tmp2 = getelementptr i32* %P, i32 %i_addr.09.0 ; <i32*> [#uses=1]
|
|
|
|
store i32 %A, i32* %tmp2
|
2010-02-12 11:34:29 +01:00
|
|
|
store i32 %indvar, i32* null
|
2007-04-03 02:13:16 +02:00
|
|
|
%indvar.next = add i32 %indvar, 1 ; <i32> [#uses=2]
|
|
|
|
icmp eq i32 %indvar.next, %i ; <i1>:1 [#uses=1]
|
|
|
|
br i1 %1, label %return, label %bb
|
|
|
|
|
|
|
|
return: ; preds = %bb, %entry
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|