|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 |
| 2 | +; RUN: opt -S < %s -passes=loop-vectorize -force-vector-width=2 | FileCheck %s |
| 3 | +;; Tests that when we simplify the loop-exit branch condition, we preserve the |
| 4 | +;; !dbg attachment for all loop-exit branches. |
| 5 | + |
| 6 | +define i32 @foo(ptr %p) { |
| 7 | +; CHECK-LABEL: define i32 @foo( |
| 8 | +; CHECK-SAME: ptr [[P:%.*]]) { |
| 9 | +; CHECK-NEXT: [[ENTRY:.*]]: |
| 10 | +; CHECK-NEXT: br i1 false, label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]] |
| 11 | +; CHECK: [[VECTOR_PH]]: |
| 12 | +; CHECK-NEXT: br label %[[VECTOR_BODY:.*]] |
| 13 | +; CHECK: [[VECTOR_BODY]]: |
| 14 | +; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ], !dbg [[DBG3:![0-9]+]] |
| 15 | +; CHECK-NEXT: store i8 0, ptr [[P]], align 1, !dbg [[DBG7:![0-9]+]] |
| 16 | +; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 2, !dbg [[DBG3]] |
| 17 | +; CHECK-NEXT: br i1 true, label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !dbg [[DBG3]], !llvm.loop [[LOOP8:![0-9]+]] |
| 18 | +; CHECK: [[MIDDLE_BLOCK]]: |
| 19 | +; CHECK-NEXT: br i1 true, label %[[EXIT:.*]], label %[[SCALAR_PH]], !dbg [[DBG11:![0-9]+]] |
| 20 | +; CHECK: [[SCALAR_PH]]: |
| 21 | +; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 2, %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ], !dbg [[DBG3]] |
| 22 | +; CHECK-NEXT: br label %[[LOOP:.*]] |
| 23 | +; CHECK: [[LOOP]]: |
| 24 | +; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[IV_NEXT:%.*]], %[[LOOP]] ], [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], !dbg [[DBG3]] |
| 25 | +; CHECK-NEXT: [[CONV:%.*]] = trunc i64 0 to i8, !dbg [[DBG12:![0-9]+]] |
| 26 | +; CHECK-NEXT: store i8 [[CONV]], ptr [[P]], align 1, !dbg [[DBG7]] |
| 27 | +; CHECK-NEXT: [[IV_NEXT]] = add i64 [[IV]], 1, !dbg [[DBG13:![0-9]+]] |
| 28 | +; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV]], 1, !dbg [[DBG14:![0-9]+]] |
| 29 | +; CHECK-NEXT: br i1 [[EXITCOND]], label %[[EXIT]], label %[[LOOP]], !dbg [[DBG11]], !llvm.loop [[LOOP15:![0-9]+]] |
| 30 | +; CHECK: [[EXIT]]: |
| 31 | +; CHECK-NEXT: ret i32 0 |
| 32 | +; |
| 33 | +entry: |
| 34 | + br label %loop |
| 35 | + |
| 36 | +loop: ; preds = %loop, %entry |
| 37 | + %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ], !dbg !3 |
| 38 | + %conv = trunc i64 0 to i8, !dbg !4 |
| 39 | + store i8 %conv, ptr %p, align 1, !dbg !5 |
| 40 | + %iv.next = add i64 %iv, 1, !dbg !6 |
| 41 | + %exitcond = icmp eq i64 %iv, 1, !dbg !7 |
| 42 | + br i1 %exitcond, label %exit, label %loop, !dbg !8 |
| 43 | + |
| 44 | +exit: ; preds = %loop |
| 45 | + ret i32 0 |
| 46 | +} |
| 47 | + |
| 48 | +!llvm.dbg.cu = !{!0} |
| 49 | +!llvm.module.flags = !{!2} |
| 50 | + |
| 51 | +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 20.0.0git") |
| 52 | +!1 = !DIFile(filename: "test.cpp", directory: "/") |
| 53 | +!2 = !{i32 2, !"Debug Info Version", i32 3} |
| 54 | +!3 = !DILocation(line: 4, scope: !9) |
| 55 | +!4 = !DILocation(line: 5, scope: !9) |
| 56 | +!5 = !DILocation(line: 6, scope: !9) |
| 57 | +!6 = !DILocation(line: 7, scope: !9) |
| 58 | +!7 = !DILocation(line: 8, scope: !9) |
| 59 | +!8 = !DILocation(line: 9, scope: !9) |
| 60 | +!9 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 11, type: !10, unit: !0, retainedNodes: !11) |
| 61 | +!10 = distinct !DISubroutineType(types: !11) |
| 62 | +!11 = !{} |
| 63 | +;. |
| 64 | +; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: [[META1:![0-9]+]], producer: "{{.*}}clang version {{.*}}", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug) |
| 65 | +; CHECK: [[META1]] = !DIFile(filename: "test.cpp", directory: {{.*}}) |
| 66 | +; CHECK: [[DBG3]] = !DILocation(line: 4, scope: [[META4:![0-9]+]]) |
| 67 | +; CHECK: [[META4]] = distinct !DISubprogram(name: "foo", scope: [[META1]], file: [[META1]], line: 11, type: [[META5:![0-9]+]], spFlags: DISPFlagDefinition, unit: [[META0]], retainedNodes: [[META6:![0-9]+]]) |
| 68 | +; CHECK: [[META5]] = distinct !DISubroutineType(types: [[META6]]) |
| 69 | +; CHECK: [[META6]] = !{} |
| 70 | +; CHECK: [[DBG7]] = !DILocation(line: 6, scope: [[META4]]) |
| 71 | +; CHECK: [[LOOP8]] = distinct !{[[LOOP8]], [[META9:![0-9]+]], [[META10:![0-9]+]]} |
| 72 | +; CHECK: [[META9]] = !{!"llvm.loop.isvectorized", i32 1} |
| 73 | +; CHECK: [[META10]] = !{!"llvm.loop.unroll.runtime.disable"} |
| 74 | +; CHECK: [[DBG11]] = !DILocation(line: 9, scope: [[META4]]) |
| 75 | +; CHECK: [[DBG12]] = !DILocation(line: 5, scope: [[META4]]) |
| 76 | +; CHECK: [[DBG13]] = !DILocation(line: 7, scope: [[META4]]) |
| 77 | +; CHECK: [[DBG14]] = !DILocation(line: 8, scope: [[META4]]) |
| 78 | +; CHECK: [[LOOP15]] = distinct !{[[LOOP15]], [[META10]], [[META9]]} |
| 79 | +;. |
0 commit comments