1; RUN: opt -S -loop-rotate < %s | FileCheck %s 2 3declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone 4declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone 5 6define i32 @tak(i32 %x, i32 %y, i32 %z) nounwind ssp { 7; CHECK-LABEL: define i32 @tak( 8; CHECK: entry 9; CHECK-NEXT: call void @llvm.dbg.value(metadata !{i32 %x} 10 11entry: 12 br label %tailrecurse 13 14tailrecurse: ; preds = %if.then, %entry 15 %x.tr = phi i32 [ %x, %entry ], [ %call, %if.then ] 16 %y.tr = phi i32 [ %y, %entry ], [ %call9, %if.then ] 17 %z.tr = phi i32 [ %z, %entry ], [ %call14, %if.then ] 18 tail call void @llvm.dbg.value(metadata !{i32 %x.tr}, i64 0, metadata !6), !dbg !7 19 tail call void @llvm.dbg.value(metadata !{i32 %y.tr}, i64 0, metadata !8), !dbg !9 20 tail call void @llvm.dbg.value(metadata !{i32 %z.tr}, i64 0, metadata !10), !dbg !11 21 %cmp = icmp slt i32 %y.tr, %x.tr, !dbg !12 22 br i1 %cmp, label %if.then, label %if.end, !dbg !12 23 24if.then: ; preds = %tailrecurse 25 %sub = sub nsw i32 %x.tr, 1, !dbg !14 26 %call = tail call i32 @tak(i32 %sub, i32 %y.tr, i32 %z.tr), !dbg !14 27 %sub6 = sub nsw i32 %y.tr, 1, !dbg !14 28 %call9 = tail call i32 @tak(i32 %sub6, i32 %z.tr, i32 %x.tr), !dbg !14 29 %sub11 = sub nsw i32 %z.tr, 1, !dbg !14 30 %call14 = tail call i32 @tak(i32 %sub11, i32 %x.tr, i32 %y.tr), !dbg !14 31 br label %tailrecurse 32 33if.end: ; preds = %tailrecurse 34 br label %return, !dbg !16 35 36return: ; preds = %if.end 37 ret i32 %z.tr, !dbg !17 38} 39 40@channelColumns = external global i64 41@horzPlane = external global i8*, align 8 42 43define void @FindFreeHorzSeg(i64 %startCol, i64 %row, i64* %rowStart) { 44; Ensure that the loop increment basic block is rotated into the tail of the 45; body, even though it contains a debug intrinsic call. 46; CHECK-LABEL: define void @FindFreeHorzSeg( 47; CHECK: %dec = add 48; CHECK-NEXT: tail call void @llvm.dbg.value 49; CHECK-NEXT: br i1 %tobool, label %for.cond, label %for.end 50 51entry: 52 br label %for.cond 53 54for.cond: 55 %i.0 = phi i64 [ %startCol, %entry ], [ %dec, %for.inc ] 56 %cmp = icmp eq i64 %i.0, 0 57 br i1 %cmp, label %for.end, label %for.body 58 59for.body: 60 %0 = load i64* @channelColumns, align 8 61 %mul = mul i64 %0, %row 62 %add = add i64 %mul, %i.0 63 %1 = load i8** @horzPlane, align 8 64 %arrayidx = getelementptr inbounds i8* %1, i64 %add 65 %2 = load i8* %arrayidx, align 1 66 %tobool = icmp eq i8 %2, 0 67 br i1 %tobool, label %for.inc, label %for.end 68 69for.inc: 70 %dec = add i64 %i.0, -1 71 tail call void @llvm.dbg.value(metadata !{i64 %dec}, i64 0, metadata !{metadata !"undef"}) 72 br label %for.cond 73 74for.end: 75 %add1 = add i64 %i.0, 1 76 store i64 %add1, i64* %rowStart, align 8 77 ret void 78} 79 80!llvm.dbg.sp = !{!0} 81 82!0 = metadata !{i32 589870, metadata !18, metadata !1, metadata !"tak", metadata !"tak", metadata !"", i32 32, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 false, i32 (i32, i32, i32)* @tak, null, null, null, i32 0} ; [ DW_TAG_subprogram ] 83!1 = metadata !{i32 589865, metadata !18} ; [ DW_TAG_file_type ] 84!2 = metadata !{i32 589841, metadata !18, i32 12, metadata !"clang version 2.9 (trunk 125492)", i1 true, metadata !"", i32 0, metadata !19, metadata !19, null, null, null, metadata !""} ; [ DW_TAG_compile_unit ] 85!3 = metadata !{i32 589845, metadata !18, metadata !1, metadata !"", i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !4, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] 86!4 = metadata !{metadata !5} 87!5 = metadata !{i32 589860, null, metadata !2, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] 88!6 = metadata !{i32 590081, metadata !0, metadata !"x", metadata !1, i32 32, metadata !5, i32 0} ; [ DW_TAG_arg_variable ] 89!7 = metadata !{i32 32, i32 13, metadata !0, null} 90!8 = metadata !{i32 590081, metadata !0, metadata !"y", metadata !1, i32 32, metadata !5, i32 0} ; [ DW_TAG_arg_variable ] 91!9 = metadata !{i32 32, i32 20, metadata !0, null} 92!10 = metadata !{i32 590081, metadata !0, metadata !"z", metadata !1, i32 32, metadata !5, i32 0} ; [ DW_TAG_arg_variable ] 93!11 = metadata !{i32 32, i32 27, metadata !0, null} 94!12 = metadata !{i32 33, i32 3, metadata !13, null} 95!13 = metadata !{i32 589835, metadata !18, metadata !0, i32 32, i32 30, i32 6} ; [ DW_TAG_lexical_block ] 96!14 = metadata !{i32 34, i32 5, metadata !15, null} 97!15 = metadata !{i32 589835, metadata !18, metadata !13, i32 33, i32 14, i32 7} ; [ DW_TAG_lexical_block ] 98!16 = metadata !{i32 36, i32 3, metadata !13, null} 99!17 = metadata !{i32 37, i32 1, metadata !13, null} 100!18 = metadata !{metadata !"/Volumes/Lalgate/cj/llvm/projects/llvm-test/SingleSource/Benchmarks/BenchmarkGame/recursive.c", metadata !"/Volumes/Lalgate/cj/D/projects/llvm-test/SingleSource/Benchmarks/BenchmarkGame"} 101!19 = metadata !{i32 0} 102