1cee313d2SEric Christopher; RUN: opt < %s -S -loop-unroll -unroll-runtime -unroll-count=2 -unroll-runtime-epilog=true | FileCheck %s -check-prefix=EPILOG
2cee313d2SEric Christopher; RUN: opt < %s -S -loop-unroll -unroll-runtime -unroll-count=2 -unroll-runtime-epilog=false | FileCheck %s -check-prefix=PROLOG
3cee313d2SEric Christopher
4a95796a3SArthur Eubanks; RUN: opt < %s -S -passes='require<opt-remark-emit>,loop-unroll' -unroll-runtime -unroll-count=2 -unroll-runtime-epilog=true | FileCheck %s -check-prefix=EPILOG
5a95796a3SArthur Eubanks; RUN: opt < %s -S -passes='require<opt-remark-emit>,loop-unroll' -unroll-runtime -unroll-count=2 -unroll-runtime-epilog=false | FileCheck %s -check-prefix=PROLOG
6cee313d2SEric Christopher
7cee313d2SEric Christopher; This tests that setting the unroll count works
8cee313d2SEric Christopher
9cee313d2SEric Christopher
10cee313d2SEric Christopher; EPILOG: for.body.preheader:
11cee313d2SEric Christopher; EPILOG:   br i1 %1, label %for.end.loopexit.unr-lcssa, label %for.body.preheader.new, !dbg [[PH_LOC:![0-9]+]]
12cee313d2SEric Christopher; EPILOG: for.body:
131251cac6SOrlando Cazalet-Hyams; EPILOG:   br i1 %niter.ncmp.1, label %for.end.loopexit.unr-lcssa.loopexit, label %for.body, !dbg [[PH_LOC]]
14cee313d2SEric Christopher; EPILOG-NOT: br i1 %niter.ncmp.2, label %for.end.loopexit{{.*}}, label %for.body
15cee313d2SEric Christopher; EPILOG: for.body.epil.preheader:
161251cac6SOrlando Cazalet-Hyams; EPILOG:   br label %for.body.epil, !dbg [[PH_LOC]]
17cee313d2SEric Christopher; EPILOG: for.body.epil:
18*b604fcb7SPhilip Reames; EPILOG:   br label %for.end.loopexit, !dbg [[EXIT_LOC:![0-9]+]]
19cee313d2SEric Christopher; EPILOG: for.end.loopexit:
20*b604fcb7SPhilip Reames; EPILOG:   br label %for.end, !dbg [[EXIT_LOC]]
21cee313d2SEric Christopher
221251cac6SOrlando Cazalet-Hyams; EPILOG-DAG: [[PH_LOC]] = !DILocation(line: 102, column: 1, scope: !{{.*}})
23cee313d2SEric Christopher; EPILOG-DAG: [[EXIT_LOC]] = !DILocation(line: 103, column: 1, scope: !{{.*}})
24cee313d2SEric Christopher
25cee313d2SEric Christopher; PROLOG: for.body.preheader:
26cee313d2SEric Christopher; PROLOG:   br {{.*}} label %for.body.prol.preheader, label %for.body.prol.loopexit, !dbg [[PH_LOC:![0-9]+]]
27cee313d2SEric Christopher; PROLOG: for.body.prol:
281251cac6SOrlando Cazalet-Hyams; PROLOG:   br label %for.body.prol.loopexit, !dbg [[PH_LOC:![0-9]+]]
29cee313d2SEric Christopher; PROLOG: for.body.prol.loopexit:
30cee313d2SEric Christopher; PROLOG:   br {{.*}} label %for.end.loopexit, label %for.body.preheader.new, !dbg [[PH_LOC]]
31cee313d2SEric Christopher; PROLOG: for.body:
321251cac6SOrlando Cazalet-Hyams; PROLOG:   br i1 %exitcond.1, label %for.end.loopexit.unr-lcssa, label %for.body, !dbg [[PH_LOC]]
33cee313d2SEric Christopher; PROLOG-NOT: br i1 %exitcond.4, label %for.end.loopexit{{.*}}, label %for.body
34cee313d2SEric Christopher
351251cac6SOrlando Cazalet-Hyams; PROLOG-DAG: [[PH_LOC]] = !DILocation(line: 102, column: 1, scope: !{{.*}})
36cee313d2SEric Christopher
37cee313d2SEric Christopherdefine i32 @test(i32* nocapture %a, i32 %n) nounwind uwtable readonly !dbg !6 {
38cee313d2SEric Christopherentry:
39cee313d2SEric Christopher  %cmp1 = icmp eq i32 %n, 0, !dbg !7
40cee313d2SEric Christopher  br i1 %cmp1, label %for.end, label %for.body, !dbg !7
41cee313d2SEric Christopher
42cee313d2SEric Christopherfor.body:                                         ; preds = %for.body, %entry
43cee313d2SEric Christopher  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
44cee313d2SEric Christopher  %sum.02 = phi i32 [ %add, %for.body ], [ 0, %entry ]
45cee313d2SEric Christopher  %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv, !dbg !8
46cee313d2SEric Christopher  %0 = load i32, i32* %arrayidx, align 4, !dbg !8
47cee313d2SEric Christopher  %add = add nsw i32 %0, %sum.02, !dbg !8
48cee313d2SEric Christopher  %indvars.iv.next = add i64 %indvars.iv, 1, !dbg !9
49cee313d2SEric Christopher  %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !9
50cee313d2SEric Christopher  %exitcond = icmp eq i32 %lftr.wideiv, %n, !dbg !9
51cee313d2SEric Christopher  br i1 %exitcond, label %for.end, label %for.body, !dbg !9
52cee313d2SEric Christopher
53cee313d2SEric Christopherfor.end:                                          ; preds = %for.body, %entry
54cee313d2SEric Christopher  %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.body ]
55cee313d2SEric Christopher  ret i32 %sum.0.lcssa, !dbg !10
56cee313d2SEric Christopher}
57cee313d2SEric Christopher
58cee313d2SEric Christopher!llvm.module.flags = !{!0, !1, !2}
59cee313d2SEric Christopher!llvm.dbg.cu = !{!11}
60cee313d2SEric Christopher!0 = !{i32 2, !"Dwarf Version", i32 4}
61cee313d2SEric Christopher!1 = !{i32 2, !"Debug Info Version", i32 3}
62cee313d2SEric Christopher!2 = !{i32 1, !"PIC Level", i32 2}
63cee313d2SEric Christopher
64cee313d2SEric Christopher!3 = !{}
65cee313d2SEric Christopher!4 = !DISubroutineType(types: !3)
66cee313d2SEric Christopher!5 = !DIFile(filename: "test.cpp", directory: "/tmp")
67cee313d2SEric Christopher!6 = distinct !DISubprogram(name: "test", scope: !5, file: !5, line: 99, type: !4, isLocal: false, isDefinition: true, scopeLine: 100, flags: DIFlagPrototyped, isOptimized: false, unit: !11, retainedNodes: !3)
68cee313d2SEric Christopher!7 = !DILocation(line: 100, column: 1, scope: !6)
69cee313d2SEric Christopher!8 = !DILocation(line: 101, column: 1, scope: !6)
70cee313d2SEric Christopher!9 = !DILocation(line: 102, column: 1, scope: !6)
71cee313d2SEric Christopher!10 = !DILocation(line: 103, column: 1, scope: !6)
72cee313d2SEric Christopher!11 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang",
73cee313d2SEric Christopher                             file: !5,
74cee313d2SEric Christopher                             isOptimized: true, flags: "-O2",
75cee313d2SEric Christopher                             splitDebugFilename: "abc.debug", emissionKind: 2)
76