[SCEV] Improve Scalar Evolution's use of no {un,}signed wrap flags
[oota-llvm.git] / test / Transforms / LoopUnroll / nsw-tripcount.ll
1 ; RUN: opt -loop-unroll -S %s | FileCheck %s
2
3 ; extern void f(int);
4 ; void test1(int v) {
5 ;   for (int i=v; i<=v+1; ++i)
6 ;     f(i);
7 ; }
8 ;
9 ; We can use the nsw information to see that the tripcount will be 2, so the
10 ; loop should be unrolled as this is always beneficial
11
12 declare void @f(i32)
13
14 ; CHECK-LABEL: @test1
15 define void @test1(i32 %v) {
16 entry:
17   %add = add nsw i32 %v, 1
18   br label %for.body
19
20 for.body:
21   %i.04 = phi i32 [ %v, %entry ], [ %inc, %for.body ]
22   tail call void @f(i32 %i.04)
23   %inc = add nsw i32 %i.04, 1
24   %cmp = icmp slt i32 %i.04, %add
25   br i1 %cmp, label %for.body, label %for.end
26
27 ; CHECK: call void @f
28 ; CHECK-NOT: br i1
29 ; CHECK: call void @f
30 for.end:
31   ret void
32 }