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