| Manman Ren | 620e978 | 2013-07-29 20:18:19 +0000 | [diff] [blame] | 1 | ; RUN: opt -S -loop-rotate < %s | FileCheck %s |
| Devang Patel | 3058398 | 2011-02-14 23:03:23 +0000 | [diff] [blame] | 2 | |
| Adrian Prantl | 87b7eb9 | 2014-10-01 18:55:02 +0000 | [diff] [blame] | 3 | declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone |
| 4 | declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone |
| Chandler Carruth | 28192c9 | 2012-04-07 19:22:18 +0000 | [diff] [blame] | 5 | |
| Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 6 | define i32 @tak(i32 %x, i32 %y, i32 %z) nounwind ssp !dbg !0 { |
| Stephen Lin | a76289a | 2013-07-14 01:50:49 +0000 | [diff] [blame] | 7 | ; CHECK-LABEL: define i32 @tak( |
| Devang Patel | 3058398 | 2011-02-14 23:03:23 +0000 | [diff] [blame] | 8 | ; CHECK: entry |
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 9 | ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 %x |
| Devang Patel | 3058398 | 2011-02-14 23:03:23 +0000 | [diff] [blame] | 10 | |
| Devang Patel | 3058398 | 2011-02-14 23:03:23 +0000 | [diff] [blame] | 11 | entry: |
| 12 | br label %tailrecurse |
| 13 | |
| 14 | tailrecurse: ; 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 ] |
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 18 | tail call void @llvm.dbg.value(metadata i32 %x.tr, i64 0, metadata !6, metadata !DIExpression()), !dbg !7 |
| 19 | tail call void @llvm.dbg.value(metadata i32 %y.tr, i64 0, metadata !8, metadata !DIExpression()), !dbg !9 |
| 20 | tail call void @llvm.dbg.value(metadata i32 %z.tr, i64 0, metadata !10, metadata !DIExpression()), !dbg !11 |
| Devang Patel | 3058398 | 2011-02-14 23:03:23 +0000 | [diff] [blame] | 21 | %cmp = icmp slt i32 %y.tr, %x.tr, !dbg !12 |
| 22 | br i1 %cmp, label %if.then, label %if.end, !dbg !12 |
| 23 | |
| 24 | if.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 | |
| 33 | if.end: ; preds = %tailrecurse |
| 34 | br label %return, !dbg !16 |
| 35 | |
| 36 | return: ; preds = %if.end |
| 37 | ret i32 %z.tr, !dbg !17 |
| 38 | } |
| 39 | |
| Chandler Carruth | 28192c9 | 2012-04-07 19:22:18 +0000 | [diff] [blame] | 40 | @channelColumns = external global i64 |
| 41 | @horzPlane = external global i8*, align 8 |
| 42 | |
| 43 | define 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. |
| Stephen Lin | a76289a | 2013-07-14 01:50:49 +0000 | [diff] [blame] | 46 | ; CHECK-LABEL: define void @FindFreeHorzSeg( |
| Chandler Carruth | 28192c9 | 2012-04-07 19:22:18 +0000 | [diff] [blame] | 47 | ; CHECK: %dec = add |
| 48 | ; CHECK-NEXT: tail call void @llvm.dbg.value |
| Yi Jiang | ab19fff | 2014-10-29 20:19:47 +0000 | [diff] [blame] | 49 | ; CHECK: %cmp = icmp |
| 50 | ; CHECK: br i1 %cmp |
| 51 | ; CHECK: phi i64 [ %{{[^,]*}}, %{{[^,]*}} ] |
| Chandler Carruth | d4be9dc | 2014-01-29 13:16:53 +0000 | [diff] [blame] | 52 | ; CHECK-NEXT: br label %for.end |
| 53 | |
| Chandler Carruth | 28192c9 | 2012-04-07 19:22:18 +0000 | [diff] [blame] | 54 | |
| 55 | entry: |
| 56 | br label %for.cond |
| 57 | |
| 58 | for.cond: |
| 59 | %i.0 = phi i64 [ %startCol, %entry ], [ %dec, %for.inc ] |
| 60 | %cmp = icmp eq i64 %i.0, 0 |
| 61 | br i1 %cmp, label %for.end, label %for.body |
| 62 | |
| 63 | for.body: |
| David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 64 | %0 = load i64, i64* @channelColumns, align 8 |
| Chandler Carruth | 28192c9 | 2012-04-07 19:22:18 +0000 | [diff] [blame] | 65 | %mul = mul i64 %0, %row |
| 66 | %add = add i64 %mul, %i.0 |
| David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 67 | %1 = load i8*, i8** @horzPlane, align 8 |
| David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 68 | %arrayidx = getelementptr inbounds i8, i8* %1, i64 %add |
| David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 69 | %2 = load i8, i8* %arrayidx, align 1 |
| Chandler Carruth | 28192c9 | 2012-04-07 19:22:18 +0000 | [diff] [blame] | 70 | %tobool = icmp eq i8 %2, 0 |
| 71 | br i1 %tobool, label %for.inc, label %for.end |
| 72 | |
| 73 | for.inc: |
| 74 | %dec = add i64 %i.0, -1 |
| Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 75 | tail call void @llvm.dbg.value(metadata i64 %dec, i64 0, metadata !DILocalVariable(scope: !0), metadata !DIExpression()), !dbg !DILocation(scope: !0) |
| Chandler Carruth | 28192c9 | 2012-04-07 19:22:18 +0000 | [diff] [blame] | 76 | br label %for.cond |
| 77 | |
| 78 | for.end: |
| 79 | %add1 = add i64 %i.0, 1 |
| 80 | store i64 %add1, i64* %rowStart, align 8 |
| 81 | ret void |
| 82 | } |
| Devang Patel | 3058398 | 2011-02-14 23:03:23 +0000 | [diff] [blame] | 83 | |
| Manman Ren | d664bd7 | 2013-11-23 01:16:29 +0000 | [diff] [blame] | 84 | !llvm.module.flags = !{!20} |
| Devang Patel | 3058398 | 2011-02-14 23:03:23 +0000 | [diff] [blame] | 85 | !llvm.dbg.sp = !{!0} |
| 86 | |
| Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 87 | !0 = distinct !DISubprogram(name: "tak", line: 32, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, file: !18, scope: !1, type: !3) |
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 88 | !1 = !DIFile(filename: "/Volumes/Lalgate/cj/llvm/projects/llvm-test/SingleSource/Benchmarks/BenchmarkGame/recursive.c", directory: "/Volumes/Lalgate/cj/D/projects/llvm-test/SingleSource/Benchmarks/BenchmarkGame") |
| Duncan P. N. Exon Smith | 55ca964 | 2015-08-03 17:26:41 +0000 | [diff] [blame] | 89 | !2 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 2.9 (trunk 125492)", isOptimized: true, emissionKind: 0, file: !18, enums: !19, retainedTypes: !19) |
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 90 | !3 = !DISubroutineType(types: !4) |
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 91 | !4 = !{!5} |
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 92 | !5 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) |
| Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 93 | !6 = !DILocalVariable(name: "x", line: 32, arg: 1, scope: !0, file: !1, type: !5) |
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 94 | !7 = !DILocation(line: 32, column: 13, scope: !0) |
| Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 95 | !8 = !DILocalVariable(name: "y", line: 32, arg: 2, scope: !0, file: !1, type: !5) |
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 96 | !9 = !DILocation(line: 32, column: 20, scope: !0) |
| Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 97 | !10 = !DILocalVariable(name: "z", line: 32, arg: 3, scope: !0, file: !1, type: !5) |
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 98 | !11 = !DILocation(line: 32, column: 27, scope: !0) |
| 99 | !12 = !DILocation(line: 33, column: 3, scope: !13) |
| 100 | !13 = distinct !DILexicalBlock(line: 32, column: 30, file: !18, scope: !0) |
| 101 | !14 = !DILocation(line: 34, column: 5, scope: !15) |
| 102 | !15 = distinct !DILexicalBlock(line: 33, column: 14, file: !18, scope: !13) |
| 103 | !16 = !DILocation(line: 36, column: 3, scope: !13) |
| 104 | !17 = !DILocation(line: 37, column: 1, scope: !13) |
| 105 | !18 = !DIFile(filename: "/Volumes/Lalgate/cj/llvm/projects/llvm-test/SingleSource/Benchmarks/BenchmarkGame/recursive.c", directory: "/Volumes/Lalgate/cj/D/projects/llvm-test/SingleSource/Benchmarks/BenchmarkGame") |
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 106 | !19 = !{i32 0} |
| Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 107 | !20 = !{i32 1, !"Debug Info Version", i32 3} |