1 ; RUN: opt -S -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck %s --match-full-lines
3 ; Make sure we reset the debug location when folding instructions.
4 ; CHECK-LABEL: define {{.+}} @patatino({{.+}}
5 ; CHECK: [[VAL:%.*]] = and i32 %c2, %k
6 ; CHECK-NEXT: [[VAL2:%.*]] icmp eq i32 [[VAL]], 0
10 define i32 @patatino(i32 %k, i32 %c1, i32 %c2) !dbg !6 {
11 %1 = and i32 %c1, %k, !dbg !8
12 %2 = icmp eq i32 %1, 0, !dbg !9
13 br i1 %2, label %8, label %3, !dbg !10
16 %4 = and i32 %c2, %k, !dbg !11
17 %5 = icmp eq i32 %4, 0, !dbg !12
18 br i1 %5, label %8, label %6, !dbg !13
21 %7 = tail call i32 (...) @bar(), !dbg !14
25 ret i32 undef, !dbg !16
28 ; All instructions involved in folding have the same !dbg location. Make sure
30 define void @dbg_all_equal(i32 %k, i32 %c1, i32 %c2) !dbg !17 {
31 ; CHECK-LABEL: define {{.+}} @dbg_all_equal({{.+}}
32 ; CHECK-NEXT: [[A1:%[a-z0-9]+]] = and i32 %c1, %k, !dbg [[DBG:![0-9]+]]
33 ; CHECK-NEXT: [[C1:%[a-z0-9]+]] = icmp eq i32 [[A1]], 0, !dbg [[DBG]]
34 ; CHECK-NEXT: [[A2:%[a-z0-9]+]] = and i32 %c2, %k, !dbg [[DBG]]
35 ; CHECK-NEXT: [[C2:%[a-z0-9]+]] = icmp eq i32 [[A2]], 0, !dbg [[DBG]]
36 ; CHECK-NEXT: [[OR:%[.a-z0-9]+]] = select i1 [[C1]], i1 true, i1 [[C2]], !dbg [[DBG]]
37 ; CHECK-NEXT: br i1 [[OR]], label {{.+}}, label {{.+}}, !dbg [[DBG]]
39 %1 = and i32 %c1, %k, !dbg !18
40 %2 = icmp eq i32 %1, 0, !dbg !18
41 br i1 %2, label %8, label %3, !dbg !18
44 %4 = and i32 %c2, %k, !dbg !18
45 %5 = icmp eq i32 %4, 0, !dbg !18
46 br i1 %5, label %8, label %6, !dbg !18
49 %7 = tail call i32 (...) @bar(), !dbg !18
57 !llvm.debugify = !{!3, !4}
58 !llvm.module.flags = !{!5}
60 !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
61 !1 = !DIFile(filename: "a.ll", directory: "/")
65 !5 = !{i32 2, !"Debug Info Version", i32 3}
66 !6 = distinct !DISubprogram(name: "patatino", linkageName: "patatino", scope: null, file: !1, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
67 !7 = !DISubroutineType(types: !2)
68 !8 = !DILocation(line: 1, column: 1, scope: !6)
69 !9 = !DILocation(line: 2, column: 1, scope: !6)
70 !10 = !DILocation(line: 3, column: 1, scope: !6)
71 !11 = !DILocation(line: 4, column: 1, scope: !6)
72 !12 = !DILocation(line: 5, column: 1, scope: !6)
73 !13 = !DILocation(line: 6, column: 1, scope: !6)
74 !14 = !DILocation(line: 7, column: 1, scope: !6)
75 !15 = !DILocation(line: 8, column: 1, scope: !6)
76 !16 = !DILocation(line: 9, column: 1, scope: !6)
77 !17 = distinct !DISubprogram(name: "dbg_all_equal", linkageName: "dbg_all_equal", scope: null, file: !1, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
78 !18 = !DILocation(line: 10, column: 10, scope: !17)