1 ; RUN: opt -passes=instcombine -S < %s | FileCheck %s
2 ; RUN: opt -passes=instcombine -S < %s --try-experimental-debuginfo-iterators | FileCheck %s
4 ; CHECK-LABEL: define {{.*}} @test5
5 define i16 @test5(i16 %A) !dbg !34 {
6 ; CHECK: [[and:%.*]] = and i16 %A, 15
8 %B = sext i16 %A to i32, !dbg !40
9 call void @llvm.dbg.value(metadata i32 %B, metadata !36, metadata !DIExpression()), !dbg !40
11 %C = and i32 %B, 15, !dbg !41
12 call void @llvm.dbg.value(metadata i32 %C, metadata !37, metadata !DIExpression()), !dbg !41
14 ; Preserve the dbg.value for the DCE'd 32-bit 'and'.
16 ; The high 16 bits of the original 'and' require sign-extending the new 16-bit and:
17 ; CHECK-NEXT: #dbg_value(i16 [[and]], [[C:![0-9]+]],
18 ; CHECK-SAME: !DIExpression(DW_OP_LLVM_convert, 16, DW_ATE_signed, DW_OP_LLVM_convert, 32, DW_ATE_signed, DW_OP_stack_value)
20 %D = trunc i32 %C to i16, !dbg !42
21 call void @llvm.dbg.value(metadata i16 %D, metadata !38, metadata !DIExpression()), !dbg !42
23 ; The dbg.value for a truncate should simply point to the result of the 16-bit 'and'.
24 ; CHECK-NEXT: #dbg_value(i16 [[and]], [[D:![0-9]+]], !DIExpression(),
27 ; CHECK-NEXT: ret i16 [[and]]
30 declare void @llvm.dbg.value(metadata, metadata, metadata)
33 !llvm.module.flags = !{!5}
35 !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
36 !1 = !DIFile(filename: "void", directory: "/")
38 !5 = !{i32 2, !"Debug Info Version", i32 3}
39 !7 = !DISubroutineType(types: !2)
40 !10 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_signed)
41 !12 = !DIBasicType(name: "ty8", size: 8, encoding: DW_ATE_signed)
42 !34 = distinct !DISubprogram(name: "test5", linkageName: "test5", scope: null, file: !1, line: 12, type: !7, isLocal: false, isDefinition: true, scopeLine: 12, isOptimized: true, unit: !0, retainedNodes: !35)
43 !35 = !{!36, !37, !38}
44 !36 = !DILocalVariable(name: "B", scope: !34, file: !1, line: 12, type: !10)
45 !37 = !DILocalVariable(name: "C", scope: !34, file: !1, line: 13, type: !10)
46 !38 = !DILocalVariable(name: "D", scope: !34, file: !1, line: 14, type: !39)
47 !39 = !DIBasicType(name: "ty16", size: 16, encoding: DW_ATE_signed)
48 !40 = !DILocation(line: 12, column: 1, scope: !34)
49 !41 = !DILocation(line: 13, column: 1, scope: !34)
50 !42 = !DILocation(line: 14, column: 1, scope: !34)
51 !43 = !DILocation(line: 15, column: 1, scope: !34)