llvm/test/Analysis/ScalarEvolution/sle.ll
Dan Gohman 9f93d30a26 ScalarEvolution support for <= and >= loops.
Also, generalize ScalarEvolutions's min and max recognition to handle
some new forms of min and max that this change makes more common.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102234 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-24 03:09:42 +00:00

28 lines
1.1 KiB
LLVM

; RUN: opt -analyze -scalar-evolution < %s | FileCheck %s
; ScalarEvolution should be able to use nsw information to prove that
; this loop has a finite trip count.
; CHECK: @le
; CHECK: Loop %for.body: backedge-taken count is %n
; CHECK: Loop %for.body: max backedge-taken count is 9223372036854775807
define void @le(i64 %n, double* nocapture %p) nounwind {
entry:
%cmp6 = icmp slt i64 %n, 0 ; <i1> [#uses=1]
br i1 %cmp6, label %for.end, label %for.body
for.body: ; preds = %for.body, %entry
%i = phi i64 [ %i.next, %for.body ], [ 0, %entry ] ; <i64> [#uses=2]
%arrayidx = getelementptr double* %p, i64 %i ; <double*> [#uses=2]
%t4 = load double* %arrayidx ; <double> [#uses=1]
%mul = fmul double %t4, 2.200000e+00 ; <double> [#uses=1]
store double %mul, double* %arrayidx
%i.next = add nsw i64 %i, 1 ; <i64> [#uses=2]
%cmp = icmp sgt i64 %i.next, %n ; <i1> [#uses=1]
br i1 %cmp, label %for.end, label %for.body
for.end: ; preds = %for.body, %entry
ret void
}