|
| 1 | +; RUN: opt --passes=loop-rotate %s -S -o - | FileCheck %s |
| 2 | + |
| 3 | +;; Rotate: |
| 4 | +;; +------------------> for.end. |
| 5 | +;; | |
| 6 | +;; entry -> for.cond -> for.body |
| 7 | +;; ^ | |
| 8 | +;; +-----------+ |
| 9 | +;; |
| 10 | +;; Into: |
| 11 | +;; |
| 12 | +;; +------> for.end. |
| 13 | +;; | |
| 14 | +;; entry (+ for.cond`0) -> for.body (+ for.cond) -+ |
| 15 | +;; ^ | |
| 16 | +;; +-------------------+ |
| 17 | +;; Check for.cond's duplicated store and br have their source atoms remapped. |
| 18 | + |
| 19 | +; CHECK: entry: |
| 20 | +; CHECK: store i32 0, ptr @glob, align 16, !dbg [[G3R1:![0-9]+]] |
| 21 | +; CHECK: br label %for.body, !dbg [[G4R1:![0-9]+]] |
| 22 | +; |
| 23 | +; CHECK: for.body: |
| 24 | +; CHECK: store i32 {{.*}}, ptr @glob, align 16, !dbg [[G1R1:![0-9]+]] |
| 25 | +; CHECK: [[CMP:%.*]] = icmp slt i32 {{.*}}, 100, !dbg [[G2R2:![0-9]+]] |
| 26 | +; CHECK: br i1 [[CMP]], label %for.body, label %for.end, !dbg [[G2R1:![0-9]+]] |
| 27 | +; |
| 28 | +; CHECK: [[G3R1]] = !DILocation(line: 4{{.*}}, atomGroup: 3, atomRank: 1) |
| 29 | +; CHECK: [[G4R1]] = !DILocation(line: 6{{.*}}, atomGroup: 4, atomRank: 1) |
| 30 | +; CHECK: [[G1R1]] = !DILocation(line: 4{{.*}}, atomGroup: 1, atomRank: 1) |
| 31 | +; CHECK: [[G2R2]] = !DILocation(line: 5{{.*}}, atomGroup: 2, atomRank: 2) |
| 32 | +; CHECK: [[G2R1]] = !DILocation(line: 6{{.*}}, atomGroup: 2, atomRank: 1) |
| 33 | + |
| 34 | +@glob = global i32 0 |
| 35 | + |
| 36 | +define void @test1() #0 !dbg !5 { |
| 37 | +entry: |
| 38 | + %array = alloca [20 x i32], align 16 |
| 39 | + br label %for.cond |
| 40 | + |
| 41 | +for.cond: ; preds = %for.body, %entry |
| 42 | + %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ] |
| 43 | + store i32 %i.0, ptr @glob, align 16, !dbg !DILocation(line: 4, scope: !5, atomGroup: 1, atomRank: 1) |
| 44 | + %cmp = icmp slt i32 %i.0, 100, !dbg !DILocation(line: 5, scope: !5, atomGroup: 2, atomRank: 2) |
| 45 | + br i1 %cmp, label %for.body, label %for.end, !dbg !DILocation(line: 6, scope: !5, atomGroup: 2, atomRank: 1) |
| 46 | + |
| 47 | +for.body: ; preds = %for.cond |
| 48 | + %inc = add nsw i32 %i.0, 1 |
| 49 | + store i32 0, ptr %array, align 16 |
| 50 | + br label %for.cond |
| 51 | + |
| 52 | +for.end: ; preds = %for.cond |
| 53 | + %arrayidx.lcssa = phi ptr [ %array, %for.cond ] |
| 54 | + call void @g(ptr %arrayidx.lcssa) |
| 55 | + ret void |
| 56 | +} |
| 57 | + |
| 58 | +declare void @g(ptr) |
| 59 | + |
| 60 | +attributes #0 = { nounwind ssp } |
| 61 | +attributes #1 = { noduplicate } |
| 62 | + |
| 63 | +!llvm.dbg.cu = !{!0} |
| 64 | +!llvm.debugify = !{!2, !3} |
| 65 | +!llvm.module.flags = !{!4} |
| 66 | + |
| 67 | +!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) |
| 68 | +!1 = !DIFile(filename: "test.ll", directory: "/") |
| 69 | +!2 = !{i32 12} |
| 70 | +!3 = !{i32 0} |
| 71 | +!4 = !{i32 2, !"Debug Info Version", i32 3} |
| 72 | +!5 = distinct !DISubprogram(name: "test1", linkageName: "test1", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0) |
| 73 | +!6 = !DISubroutineType(types: !7) |
| 74 | +!7 = !{} |
0 commit comments