blob: 150ae70a8262d47005569d57be32508e67621989 [file] [log] [blame]
Daniel Dunbarb994d022009-09-05 11:35:16 +00001; RUN: opt -S -indvars %s | FileCheck %s
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
Daniel Dunbarb994d022009-09-05 11:35:16 +000011; CHECK: Loop:
12; CHECK-NEXT: Canonical
Tanya Lattner4c4d0b82008-03-01 09:15:35 +000013 %NonIndvar = phi i32 [ 200, %0 ], [ %NonIndvarNext, %Loop ] ; <i32> [#uses=1]
Dan Gohmandd20dbb2009-04-28 22:03:26 +000014 %Canonical = phi i32 [ 0, %0 ], [ %CanonicalNext, %Loop ] ; <i32> [#uses=2]
15 store i32 %Canonical, i32* null
Tanya Lattner4c4d0b82008-03-01 09:15:35 +000016 %NonIndvarNext = sdiv i32 %NonIndvar, 2 ; <i32> [#uses=1]
17 %CanonicalNext = add i32 %Canonical, 1 ; <i32> [#uses=1]
18 br label %Loop
Dan Gohmanf17a25c2007-07-18 16:29:46 +000019}
20