1; RUN: opt -S -simplifycfg < %s | FileCheck %s --match-full-lines
2
3; Make sure we reset the debug location when folding instructions.
4; CHECK: [[VAL:%.*]] = and i32 %c2, %k
5; CHECK-NEXT: [[VAL2:%.*]] icmp eq i32 [[VAL]], 0
6
7declare i32 @bar(...)
8
9define i32 @patatino(i32 %k, i32 %c1, i32 %c2) !dbg !6 {
10  %1 = and i32 %c1, %k, !dbg !8
11  %2 = icmp eq i32 %1, 0, !dbg !9
12  br i1 %2, label %8, label %3, !dbg !10
13
143:
15  %4 = and i32 %c2, %k, !dbg !11
16  %5 = icmp eq i32 %4, 0, !dbg !12
17  br i1 %5, label %8, label %6, !dbg !13
18
196:
20  %7 = tail call i32 (...) @bar(), !dbg !14
21  br label %8, !dbg !15
22
238:
24  ret i32 undef, !dbg !16
25}
26
27!llvm.dbg.cu = !{!0}
28!llvm.debugify = !{!3, !4}
29!llvm.module.flags = !{!5}
30
31!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
32!1 = !DIFile(filename: "a.ll", directory: "/")
33!2 = !{}
34!3 = !{i32 9}
35!4 = !{i32 0}
36!5 = !{i32 2, !"Debug Info Version", i32 3}
37!6 = distinct !DISubprogram(name: "patatino", linkageName: "patatino", scope: null, file: !1, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
38!7 = !DISubroutineType(types: !2)
39!8 = !DILocation(line: 1, column: 1, scope: !6)
40!9 = !DILocation(line: 2, column: 1, scope: !6)
41!10 = !DILocation(line: 3, column: 1, scope: !6)
42!11 = !DILocation(line: 4, column: 1, scope: !6)
43!12 = !DILocation(line: 5, column: 1, scope: !6)
44!13 = !DILocation(line: 6, column: 1, scope: !6)
45!14 = !DILocation(line: 7, column: 1, scope: !6)
46!15 = !DILocation(line: 8, column: 1, scope: !6)
47!16 = !DILocation(line: 9, column: 1, scope: !6)
48