blob: 0459bc849bfb303967a60f43dd0618f99ac83c5e [file] [log] [blame]
Dan Gohman18800922009-09-11 18:01:28 +00001; RUN: opt < %s -loop-reduce -S | grep phi | count 1
Chris Lattnerac86efb2005-08-08 06:23:47 +00002
3; This testcase should have ONE stride 18 indvar, the other use should have a
4; loop invariant value (B) added to it inside of the loop, instead of having
5; a whole indvar based on B for it.
6
Tanya Lattnerab7872c2008-03-19 07:28:33 +00007declare i1 @cond(i32)
Chris Lattnerac86efb2005-08-08 06:23:47 +00008
Tanya Lattnerab7872c2008-03-19 07:28:33 +00009define void @test(i32 %B) {
10; <label>:0
Chris Lattnerac86efb2005-08-08 06:23:47 +000011 br label %Loop
Tanya Lattnerab7872c2008-03-19 07:28:33 +000012Loop: ; preds = %Loop, %0
13 %IV = phi i32 [ 0, %0 ], [ %IVn, %Loop ] ; <i32> [#uses=3]
14 %C = mul i32 %IV, 18 ; <i32> [#uses=1]
15 %D = mul i32 %IV, 18 ; <i32> [#uses=1]
16 %E = add i32 %D, %B ; <i32> [#uses=1]
17 %cnd = call i1 @cond( i32 %E ) ; <i1> [#uses=1]
18 call i1 @cond( i32 %C ) ; <i1>:1 [#uses=0]
19 %IVn = add i32 %IV, 1 ; <i32> [#uses=1]
20 br i1 %cnd, label %Loop, label %Out
21Out: ; preds = %Loop
Chris Lattnerac86efb2005-08-08 06:23:47 +000022 ret void
23}
Tanya Lattnerab7872c2008-03-19 07:28:33 +000024