blob: dcf159a09a1d51082d646b19bbf4d45422da4bd9 [file] [log] [blame]
Kevin Qinfc02e3c2014-09-29 11:15:00 +00001; RUN: opt < %s -S -loop-unroll -unroll-runtime -unroll-count=2 | FileCheck %s
Andrew Trickd04d15292011-12-09 06:19:40 +00002
3; This tests that setting the unroll count works
4
Alexey Samsonov770f65c2015-06-11 18:25:54 +00005; CHECK: for.body.preheader:
6; CHECK: br {{.*}} label %for.body.prol, label %for.body.preheader.split, !dbg [[PH_LOC:![0-9]+]]
Kevin Qinfc02e3c2014-09-29 11:15:00 +00007; CHECK: for.body.prol:
Alexey Samsonov770f65c2015-06-11 18:25:54 +00008; CHECK: br label %for.body.preheader.split, !dbg [[BODY_LOC:![0-9]+]]
9; CHECK: for.body.preheader.split:
10; CHECK: br {{.*}} label %for.end.loopexit, label %for.body.preheader.split.split, !dbg [[PH_LOC]]
Andrew Trickd04d15292011-12-09 06:19:40 +000011; CHECK: for.body:
Alexey Samsonov770f65c2015-06-11 18:25:54 +000012; CHECK: br i1 %exitcond.1, label %for.end.loopexit.unr-lcssa, label %for.body, !dbg [[BODY_LOC]]
Andrew Trickd04d15292011-12-09 06:19:40 +000013; CHECK-NOT: br i1 %exitcond.4, label %for.end.loopexit{{.*}}, label %for.body
14
Alexey Samsonov770f65c2015-06-11 18:25:54 +000015; CHECK-DAG: [[PH_LOC]] = !DILocation(line: 101, column: 1, scope: !{{.*}})
16; CHECK-DAG: [[BODY_LOC]] = !DILocation(line: 102, column: 1, scope: !{{.*}})
17
Peter Collingbourned4bff302015-11-05 22:03:56 +000018define i32 @test(i32* nocapture %a, i32 %n) nounwind uwtable readonly !dbg !6 {
Andrew Trickd04d15292011-12-09 06:19:40 +000019entry:
Alexey Samsonov770f65c2015-06-11 18:25:54 +000020 %cmp1 = icmp eq i32 %n, 0, !dbg !7
21 br i1 %cmp1, label %for.end, label %for.body, !dbg !7
Andrew Trickd04d15292011-12-09 06:19:40 +000022
23for.body: ; preds = %for.body, %entry
24 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
25 %sum.02 = phi i32 [ %add, %for.body ], [ 0, %entry ]
Alexey Samsonov770f65c2015-06-11 18:25:54 +000026 %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv, !dbg !8
27 %0 = load i32, i32* %arrayidx, align 4, !dbg !8
28 %add = add nsw i32 %0, %sum.02, !dbg !8
29 %indvars.iv.next = add i64 %indvars.iv, 1, !dbg !9
30 %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !9
31 %exitcond = icmp eq i32 %lftr.wideiv, %n, !dbg !9
32 br i1 %exitcond, label %for.end, label %for.body, !dbg !9
Andrew Trickd04d15292011-12-09 06:19:40 +000033
34for.end: ; preds = %for.body, %entry
35 %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.body ]
Alexey Samsonov770f65c2015-06-11 18:25:54 +000036 ret i32 %sum.0.lcssa, !dbg !10
Andrew Trickd04d15292011-12-09 06:19:40 +000037}
Alexey Samsonov770f65c2015-06-11 18:25:54 +000038
39!llvm.module.flags = !{!0, !1, !2}
40!0 = !{i32 2, !"Dwarf Version", i32 4}
41!1 = !{i32 2, !"Debug Info Version", i32 3}
42!2 = !{i32 1, !"PIC Level", i32 2}
43
44!3 = !{}
45!4 = !DISubroutineType(types: !3)
46!5 = !DIFile(filename: "test.cpp", directory: "/tmp")
Peter Collingbourned4bff302015-11-05 22:03:56 +000047!6 = distinct !DISubprogram(name: "test", scope: !5, file: !5, line: 99, type: !4, isLocal: false, isDefinition: true, scopeLine: 100, flags: DIFlagPrototyped, isOptimized: false, variables: !3)
Alexey Samsonov770f65c2015-06-11 18:25:54 +000048!7 = !DILocation(line: 100, column: 1, scope: !6)
49!8 = !DILocation(line: 101, column: 1, scope: !6)
50!9 = !DILocation(line: 102, column: 1, scope: !6)
51!10 = !DILocation(line: 103, column: 1, scope: !6)