|
| 1 | +; RUN: opt %s --passes=jump-threading -S -o - -S | FileCheck %s |
| 2 | + |
| 3 | +;; +-> T1 -+ |
| 4 | +;; | v +-> T2 |
| 5 | +;; Entry -+ Merge -+ |
| 6 | +;; | ^ +-> F2 |
| 7 | +;; +-> F1 -+ |
| 8 | +;; |
| 9 | +;; Duplicate Merge into T1 then fold Merge into its only pred F1 (taking its name). |
| 10 | +;; |
| 11 | +;; +-> T1 -----> T2 |
| 12 | +;; | \ ^ |
| 13 | +;; | \ / |
| 14 | +;; | \ / |
| 15 | +;; Entry -+ +----+ |
| 16 | +;; | / v |
| 17 | +;; +--> Merge -> F2 |
| 18 | +;; |
| 19 | +;; Check the duplicated (into T1) instructions' atoms are remapped. |
| 20 | + |
| 21 | +; CHECK: T1: |
| 22 | +; CHECK-NEXT: %v1 = call i32 @f1() |
| 23 | +; CHECK-NEXT: %cond3 = icmp eq i32 %v1, 412 |
| 24 | +; CHECK-NEXT: %C1 = add i32 %v1, 1, !dbg [[G3R2:!.*]] |
| 25 | +; CHECK-NEXT: store i32 %C1, ptr %p, align 4, !dbg [[G3R1:!.*]] |
| 26 | + |
| 27 | +; CHECK: Merge: |
| 28 | +; CHECK-NEXT: %v2 = call i32 @f2() |
| 29 | +; CHECK-NEXT: store i32 1, ptr %p, align 4, !dbg [[G1R1:!.*]] |
| 30 | +; CHECK-NEXT: %C = add i32 %v2, 1, !dbg [[G2R2:!.*]] |
| 31 | +; CHECK-NEXT: store i32 %C, ptr %p, align 4, !dbg [[G2R1:!.*]] |
| 32 | + |
| 33 | +; CHECK: [[G3R2]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 2) |
| 34 | +; CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1) |
| 35 | +; CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1) |
| 36 | +; CHECK: [[G2R2]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 2) |
| 37 | +; CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1) |
| 38 | + |
| 39 | +define i32 @test5(i1 %cond, i1 %cond2, ptr %p) !dbg !5 { |
| 40 | + br i1 %cond, label %T1, label %F1 |
| 41 | + |
| 42 | +T1: ; preds = %0 |
| 43 | + %v1 = call i32 @f1() |
| 44 | + %cond3 = icmp eq i32 %v1, 412 |
| 45 | + br label %Merge |
| 46 | + |
| 47 | +F1: ; preds = %0 |
| 48 | + %v2 = call i32 @f2() |
| 49 | + store i32 1, ptr %p, align 4, !dbg !8 |
| 50 | + br label %Merge |
| 51 | + |
| 52 | +Merge: ; preds = %F1, %T1 |
| 53 | + %A = phi i1 [ %cond3, %T1 ], [ %cond2, %F1 ] |
| 54 | + %B = phi i32 [ %v1, %T1 ], [ %v2, %F1 ] |
| 55 | + %C = add i32 %B, 1, !dbg !9 |
| 56 | + store i32 %C, ptr %p, align 4, !dbg !10 |
| 57 | + br i1 %A, label %T2, label %F2 |
| 58 | + |
| 59 | +T2: ; preds = %Merge |
| 60 | + call void @f3() |
| 61 | + ret i32 %B |
| 62 | + |
| 63 | +F2: ; preds = %Merge |
| 64 | + ret i32 %B |
| 65 | +} |
| 66 | + |
| 67 | +declare i32 @f1() |
| 68 | + |
| 69 | +declare i32 @f2() |
| 70 | + |
| 71 | +declare void @f3() |
| 72 | + |
| 73 | +!llvm.dbg.cu = !{!0} |
| 74 | +!llvm.debugify = !{!2, !3} |
| 75 | +!llvm.module.flags = !{!4} |
| 76 | + |
| 77 | +!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) |
| 78 | +!1 = !DIFile(filename: "test.ll", directory: "/") |
| 79 | +!2 = !{i32 12} |
| 80 | +!3 = !{i32 0} |
| 81 | +!4 = !{i32 2, !"Debug Info Version", i32 3} |
| 82 | +!5 = distinct !DISubprogram(name: "test5", linkageName: "test5", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0) |
| 83 | +!6 = !DISubroutineType(types: !7) |
| 84 | +!7 = !{} |
| 85 | +!8 = !DILocation(line: 1, column: 1, scope: !5, atomGroup: 1, atomRank: 1) |
| 86 | +!9 = !DILocation(line: 2, column: 1, scope: !5, atomGroup: 2, atomRank: 2) |
| 87 | +!10 = !DILocation(line: 2, column: 1, scope: !5, atomGroup: 2, atomRank: 1) |
0 commit comments