blob: d70e604979787ac9099cf550eeff35cd9f6c231b [file] [log] [blame]
Tanya Lattner4c4d0b82008-03-01 09:15:35 +00001; RUN: llvm-as < %s | opt -indvars | llvm-dis | %prcontext Loop: 1 | grep %indvar
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002
3; The indvar simplification code should ensure that the first PHI in the block
4; is the canonical one!
5
Tanya Lattner4c4d0b82008-03-01 09:15:35 +00006define i32 @test() {
7; <label>:0
8 br label %Loop
Dan Gohmanf17a25c2007-07-18 16:29:46 +00009
Tanya Lattner4c4d0b82008-03-01 09:15:35 +000010Loop: ; preds = %Loop, %0
11 %NonIndvar = phi i32 [ 200, %0 ], [ %NonIndvarNext, %Loop ] ; <i32> [#uses=1]
Dan Gohmandd20dbb2009-04-28 22:03:26 +000012 %Canonical = phi i32 [ 0, %0 ], [ %CanonicalNext, %Loop ] ; <i32> [#uses=2]
13 store i32 %Canonical, i32* null
Tanya Lattner4c4d0b82008-03-01 09:15:35 +000014 %NonIndvarNext = sdiv i32 %NonIndvar, 2 ; <i32> [#uses=1]
15 %CanonicalNext = add i32 %Canonical, 1 ; <i32> [#uses=1]
16 br label %Loop
Dan Gohmanf17a25c2007-07-18 16:29:46 +000017}
18