1 ; RUN: opt < %s -indvars -S > %t
2 ; RUN: grep {%exitcond = icmp eq i64 %indvar.next, %n} %t
3 ; RUN: grep {getelementptr i8\\* %A, i64 %indvar} %t
4 ; RUN: grep getelementptr %t | count 1
5 ; RUN: grep add %t | count 1
6 ; RUN: not grep scevgep %t
7 ; RUN: not grep ptrtoint %t
9 ; Indvars should be able to expand the pointer-arithmetic
10 ; IV into an integer IV indexing into a simple getelementptr.
12 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64"
14 define void @foo(i8* %A, i64 %n) nounwind {
16 %0 = icmp eq i64 %n, 0 ; <i1> [#uses=1]
17 br i1 %0, label %return, label %bb.nph
19 bb.nph: ; preds = %entry
20 %1 = getelementptr i8* %A, i64 %n ; <i8*> [#uses=1]
23 bb: ; preds = %bb1, %bb.nph
24 %q.01 = phi i8* [ %2, %bb1 ], [ %A, %bb.nph ] ; <i8*> [#uses=2]
25 store i8 0, i8* %q.01, align 1
26 %2 = getelementptr i8* %q.01, i64 1 ; <i8*> [#uses=2]
30 %3 = icmp eq i8* %1, %2 ; <i1> [#uses=1]
31 br i1 %3, label %bb1.return_crit_edge, label %bb
33 bb1.return_crit_edge: ; preds = %bb1
36 return: ; preds = %bb1.return_crit_edge, %entry