blob: f24c4807114fd4976e76545bc07e0cc9ed9a04c0 [file] [log] [blame]
Dan Gohmanf33bac32010-04-24 03:09:42 +00001; RUN: opt -analyze -scalar-evolution < %s | FileCheck %s
2
3; ScalarEvolution should be able to use nsw information to prove that
4; this loop has a finite trip count.
5
6; CHECK: @le
7; CHECK: Loop %for.body: backedge-taken count is %n
8; CHECK: Loop %for.body: max backedge-taken count is 9223372036854775807
9
10define void @le(i64 %n, double* nocapture %p) nounwind {
11entry:
12 %cmp6 = icmp slt i64 %n, 0 ; <i1> [#uses=1]
13 br i1 %cmp6, label %for.end, label %for.body
14
15for.body: ; preds = %for.body, %entry
16 %i = phi i64 [ %i.next, %for.body ], [ 0, %entry ] ; <i64> [#uses=2]
David Blaikie79e6c742015-02-27 19:29:02 +000017 %arrayidx = getelementptr double, double* %p, i64 %i ; <double*> [#uses=2]
David Blaikiea79ac142015-02-27 21:17:42 +000018 %t4 = load double, double* %arrayidx ; <double> [#uses=1]
Dan Gohmanf33bac32010-04-24 03:09:42 +000019 %mul = fmul double %t4, 2.200000e+00 ; <double> [#uses=1]
20 store double %mul, double* %arrayidx
21 %i.next = add nsw i64 %i, 1 ; <i64> [#uses=2]
22 %cmp = icmp sgt i64 %i.next, %n ; <i1> [#uses=1]
23 br i1 %cmp, label %for.end, label %for.body
24
25for.end: ; preds = %for.body, %entry
26 ret void
27}