blob: 32463373ca9952eeebe25b7788ed32ef1e969bce [file] [log] [blame]
Michael Zolotukhinb2738e42016-08-02 21:24:14 +00001; RUN: opt < %s -S -loop-unroll -unroll-runtime -unroll-count=2 -unroll-runtime-epilog=true | FileCheck %s -check-prefix=EPILOG
David L Kreitzer188de5a2016-04-05 12:19:35 +00002; RUN: opt < %s -S -loop-unroll -unroll-runtime -unroll-count=2 -unroll-runtime-epilog=false | FileCheck %s -check-prefix=PROLOG
Andrew Trickd04d15292011-12-09 06:19:40 +00003
Teresa Johnsonecd90132017-08-02 20:35:29 +00004; RUN: opt < %s -S -passes='require<opt-remark-emit>,unroll' -unroll-runtime -unroll-count=2 -unroll-runtime-epilog=true | FileCheck %s -check-prefix=EPILOG
5; RUN: opt < %s -S -passes='require<opt-remark-emit>,unroll' -unroll-runtime -unroll-count=2 -unroll-runtime-epilog=false | FileCheck %s -check-prefix=PROLOG
Chandler Carruthce40fa12017-01-25 02:49:01 +00006
Andrew Trickd04d15292011-12-09 06:19:40 +00007; This tests that setting the unroll count works
8
Andrew Trickd04d15292011-12-09 06:19:40 +00009
David L Kreitzer188de5a2016-04-05 12:19:35 +000010; EPILOG: for.body.preheader:
Evgeny Stupachenko23ce61b2016-04-27 03:04:54 +000011; EPILOG: br i1 %1, label %for.end.loopexit.unr-lcssa, label %for.body.preheader.new, !dbg [[PH_LOC:![0-9]+]]
David L Kreitzer188de5a2016-04-05 12:19:35 +000012; EPILOG: for.body:
13; EPILOG: br i1 %niter.ncmp.1, label %for.end.loopexit.unr-lcssa.loopexit, label %for.body, !dbg [[BODY_LOC:![0-9]+]]
14; EPILOG-NOT: br i1 %niter.ncmp.2, label %for.end.loopexit{{.*}}, label %for.body
15; EPILOG: for.body.epil.preheader:
Zhaoshi Zheng8af1e1c2017-12-26 23:31:21 +000016; EPILOG: br label %for.body.epil, !dbg [[BODY_LOC]]
David L Kreitzer188de5a2016-04-05 12:19:35 +000017; EPILOG: for.body.epil:
Zhaoshi Zheng8af1e1c2017-12-26 23:31:21 +000018; EPILOG: br label %for.end.loopexit.epilog-lcssa, !dbg [[BODY_LOC]]
19; EPILOG: for.end.loopexit:
20; EPILOG: br label %for.end, !dbg [[EXIT_LOC:![0-9]+]]
David L Kreitzer188de5a2016-04-05 12:19:35 +000021
22; EPILOG-DAG: [[PH_LOC]] = !DILocation(line: 101, column: 1, scope: !{{.*}})
23; EPILOG-DAG: [[BODY_LOC]] = !DILocation(line: 102, column: 1, scope: !{{.*}})
24; EPILOG-DAG: [[EXIT_LOC]] = !DILocation(line: 103, column: 1, scope: !{{.*}})
25
26; PROLOG: for.body.preheader:
27; PROLOG: br {{.*}} label %for.body.prol.preheader, label %for.body.prol.loopexit, !dbg [[PH_LOC:![0-9]+]]
28; PROLOG: for.body.prol:
29; PROLOG: br label %for.body.prol.loopexit, !dbg [[BODY_LOC:![0-9]+]]
30; PROLOG: for.body.prol.loopexit:
31; PROLOG: br {{.*}} label %for.end.loopexit, label %for.body.preheader.new, !dbg [[PH_LOC]]
32; PROLOG: for.body:
33; PROLOG: br i1 %exitcond.1, label %for.end.loopexit.unr-lcssa, label %for.body, !dbg [[BODY_LOC]]
34; PROLOG-NOT: br i1 %exitcond.4, label %for.end.loopexit{{.*}}, label %for.body
35
36; PROLOG-DAG: [[PH_LOC]] = !DILocation(line: 101, column: 1, scope: !{{.*}})
37; PROLOG-DAG: [[BODY_LOC]] = !DILocation(line: 102, column: 1, scope: !{{.*}})
Alexey Samsonov770f65c2015-06-11 18:25:54 +000038
Peter Collingbourned4bff302015-11-05 22:03:56 +000039define i32 @test(i32* nocapture %a, i32 %n) nounwind uwtable readonly !dbg !6 {
Andrew Trickd04d15292011-12-09 06:19:40 +000040entry:
Alexey Samsonov770f65c2015-06-11 18:25:54 +000041 %cmp1 = icmp eq i32 %n, 0, !dbg !7
42 br i1 %cmp1, label %for.end, label %for.body, !dbg !7
Andrew Trickd04d15292011-12-09 06:19:40 +000043
44for.body: ; preds = %for.body, %entry
45 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
46 %sum.02 = phi i32 [ %add, %for.body ], [ 0, %entry ]
Alexey Samsonov770f65c2015-06-11 18:25:54 +000047 %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv, !dbg !8
48 %0 = load i32, i32* %arrayidx, align 4, !dbg !8
49 %add = add nsw i32 %0, %sum.02, !dbg !8
50 %indvars.iv.next = add i64 %indvars.iv, 1, !dbg !9
51 %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !9
52 %exitcond = icmp eq i32 %lftr.wideiv, %n, !dbg !9
53 br i1 %exitcond, label %for.end, label %for.body, !dbg !9
Andrew Trickd04d15292011-12-09 06:19:40 +000054
55for.end: ; preds = %for.body, %entry
56 %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.body ]
Alexey Samsonov770f65c2015-06-11 18:25:54 +000057 ret i32 %sum.0.lcssa, !dbg !10
Andrew Trickd04d15292011-12-09 06:19:40 +000058}
Alexey Samsonov770f65c2015-06-11 18:25:54 +000059
60!llvm.module.flags = !{!0, !1, !2}
Davide Italianoea040262016-04-05 23:37:08 +000061!llvm.dbg.cu = !{!11}
Alexey Samsonov770f65c2015-06-11 18:25:54 +000062!0 = !{i32 2, !"Dwarf Version", i32 4}
63!1 = !{i32 2, !"Debug Info Version", i32 3}
64!2 = !{i32 1, !"PIC Level", i32 2}
65
66!3 = !{}
67!4 = !DISubroutineType(types: !3)
68!5 = !DIFile(filename: "test.cpp", directory: "/tmp")
Adrian Prantl75819ae2016-04-15 15:57:41 +000069!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, variables: !3)
Alexey Samsonov770f65c2015-06-11 18:25:54 +000070!7 = !DILocation(line: 100, column: 1, scope: !6)
71!8 = !DILocation(line: 101, column: 1, scope: !6)
72!9 = !DILocation(line: 102, column: 1, scope: !6)
73!10 = !DILocation(line: 103, column: 1, scope: !6)
Adrian Prantl75819ae2016-04-15 15:57:41 +000074!11 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang",
Davide Italianoea040262016-04-05 23:37:08 +000075 file: !5,
76 isOptimized: true, flags: "-O2",
Adrian Prantl75819ae2016-04-15 15:57:41 +000077 splitDebugFilename: "abc.debug", emissionKind: 2)