1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -S -loop-unroll -unroll-runtime -unroll-count=2 | FileCheck %s -check-prefix=EPILOG 2*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -S -loop-unroll -unroll-runtime -unroll-count=2 -unroll-runtime-epilog=false | FileCheck %s -check-prefix=PROLOG 3*9880d681SAndroid Build Coastguard Worker 4*9880d681SAndroid Build Coastguard Worker; This tests that setting the unroll count works 5*9880d681SAndroid Build Coastguard Worker 6*9880d681SAndroid Build Coastguard Worker 7*9880d681SAndroid Build Coastguard Worker; EPILOG: for.body.preheader: 8*9880d681SAndroid Build Coastguard Worker; EPILOG: br i1 %1, label %for.end.loopexit.unr-lcssa, label %for.body.preheader.new, !dbg [[PH_LOC:![0-9]+]] 9*9880d681SAndroid Build Coastguard Worker; EPILOG: for.body: 10*9880d681SAndroid Build Coastguard Worker; EPILOG: br i1 %niter.ncmp.1, label %for.end.loopexit.unr-lcssa.loopexit, label %for.body, !dbg [[BODY_LOC:![0-9]+]] 11*9880d681SAndroid Build Coastguard Worker; EPILOG-NOT: br i1 %niter.ncmp.2, label %for.end.loopexit{{.*}}, label %for.body 12*9880d681SAndroid Build Coastguard Worker; EPILOG: for.body.epil.preheader: 13*9880d681SAndroid Build Coastguard Worker; EPILOG: br label %for.body.epil, !dbg [[EXIT_LOC:![0-9]+]] 14*9880d681SAndroid Build Coastguard Worker; EPILOG: for.body.epil: 15*9880d681SAndroid Build Coastguard Worker; EPILOG: br label %for.end.loopexit.epilog-lcssa, !dbg [[BODY_LOC:![0-9]+]] 16*9880d681SAndroid Build Coastguard Worker 17*9880d681SAndroid Build Coastguard Worker; EPILOG-DAG: [[PH_LOC]] = !DILocation(line: 101, column: 1, scope: !{{.*}}) 18*9880d681SAndroid Build Coastguard Worker; EPILOG-DAG: [[BODY_LOC]] = !DILocation(line: 102, column: 1, scope: !{{.*}}) 19*9880d681SAndroid Build Coastguard Worker; EPILOG-DAG: [[EXIT_LOC]] = !DILocation(line: 103, column: 1, scope: !{{.*}}) 20*9880d681SAndroid Build Coastguard Worker 21*9880d681SAndroid Build Coastguard Worker; PROLOG: for.body.preheader: 22*9880d681SAndroid Build Coastguard Worker; PROLOG: br {{.*}} label %for.body.prol.preheader, label %for.body.prol.loopexit, !dbg [[PH_LOC:![0-9]+]] 23*9880d681SAndroid Build Coastguard Worker; PROLOG: for.body.prol: 24*9880d681SAndroid Build Coastguard Worker; PROLOG: br label %for.body.prol.loopexit, !dbg [[BODY_LOC:![0-9]+]] 25*9880d681SAndroid Build Coastguard Worker; PROLOG: for.body.prol.loopexit: 26*9880d681SAndroid Build Coastguard Worker; PROLOG: br {{.*}} label %for.end.loopexit, label %for.body.preheader.new, !dbg [[PH_LOC]] 27*9880d681SAndroid Build Coastguard Worker; PROLOG: for.body: 28*9880d681SAndroid Build Coastguard Worker; PROLOG: br i1 %exitcond.1, label %for.end.loopexit.unr-lcssa, label %for.body, !dbg [[BODY_LOC]] 29*9880d681SAndroid Build Coastguard Worker; PROLOG-NOT: br i1 %exitcond.4, label %for.end.loopexit{{.*}}, label %for.body 30*9880d681SAndroid Build Coastguard Worker 31*9880d681SAndroid Build Coastguard Worker; PROLOG-DAG: [[PH_LOC]] = !DILocation(line: 101, column: 1, scope: !{{.*}}) 32*9880d681SAndroid Build Coastguard Worker; PROLOG-DAG: [[BODY_LOC]] = !DILocation(line: 102, column: 1, scope: !{{.*}}) 33*9880d681SAndroid Build Coastguard Worker 34*9880d681SAndroid Build Coastguard Workerdefine i32 @test(i32* nocapture %a, i32 %n) nounwind uwtable readonly !dbg !6 { 35*9880d681SAndroid Build Coastguard Workerentry: 36*9880d681SAndroid Build Coastguard Worker %cmp1 = icmp eq i32 %n, 0, !dbg !7 37*9880d681SAndroid Build Coastguard Worker br i1 %cmp1, label %for.end, label %for.body, !dbg !7 38*9880d681SAndroid Build Coastguard Worker 39*9880d681SAndroid Build Coastguard Workerfor.body: ; preds = %for.body, %entry 40*9880d681SAndroid Build Coastguard Worker %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ] 41*9880d681SAndroid Build Coastguard Worker %sum.02 = phi i32 [ %add, %for.body ], [ 0, %entry ] 42*9880d681SAndroid Build Coastguard Worker %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv, !dbg !8 43*9880d681SAndroid Build Coastguard Worker %0 = load i32, i32* %arrayidx, align 4, !dbg !8 44*9880d681SAndroid Build Coastguard Worker %add = add nsw i32 %0, %sum.02, !dbg !8 45*9880d681SAndroid Build Coastguard Worker %indvars.iv.next = add i64 %indvars.iv, 1, !dbg !9 46*9880d681SAndroid Build Coastguard Worker %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !9 47*9880d681SAndroid Build Coastguard Worker %exitcond = icmp eq i32 %lftr.wideiv, %n, !dbg !9 48*9880d681SAndroid Build Coastguard Worker br i1 %exitcond, label %for.end, label %for.body, !dbg !9 49*9880d681SAndroid Build Coastguard Worker 50*9880d681SAndroid Build Coastguard Workerfor.end: ; preds = %for.body, %entry 51*9880d681SAndroid Build Coastguard Worker %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.body ] 52*9880d681SAndroid Build Coastguard Worker ret i32 %sum.0.lcssa, !dbg !10 53*9880d681SAndroid Build Coastguard Worker} 54*9880d681SAndroid Build Coastguard Worker 55*9880d681SAndroid Build Coastguard Worker!llvm.module.flags = !{!0, !1, !2} 56*9880d681SAndroid Build Coastguard Worker!llvm.dbg.cu = !{!11} 57*9880d681SAndroid Build Coastguard Worker!0 = !{i32 2, !"Dwarf Version", i32 4} 58*9880d681SAndroid Build Coastguard Worker!1 = !{i32 2, !"Debug Info Version", i32 3} 59*9880d681SAndroid Build Coastguard Worker!2 = !{i32 1, !"PIC Level", i32 2} 60*9880d681SAndroid Build Coastguard Worker 61*9880d681SAndroid Build Coastguard Worker!3 = !{} 62*9880d681SAndroid Build Coastguard Worker!4 = !DISubroutineType(types: !3) 63*9880d681SAndroid Build Coastguard Worker!5 = !DIFile(filename: "test.cpp", directory: "/tmp") 64*9880d681SAndroid Build Coastguard Worker!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) 65*9880d681SAndroid Build Coastguard Worker!7 = !DILocation(line: 100, column: 1, scope: !6) 66*9880d681SAndroid Build Coastguard Worker!8 = !DILocation(line: 101, column: 1, scope: !6) 67*9880d681SAndroid Build Coastguard Worker!9 = !DILocation(line: 102, column: 1, scope: !6) 68*9880d681SAndroid Build Coastguard Worker!10 = !DILocation(line: 103, column: 1, scope: !6) 69*9880d681SAndroid Build Coastguard Worker!11 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang", 70*9880d681SAndroid Build Coastguard Worker file: !5, 71*9880d681SAndroid Build Coastguard Worker isOptimized: true, flags: "-O2", 72*9880d681SAndroid Build Coastguard Worker splitDebugFilename: "abc.debug", emissionKind: 2) 73