xref: /llvm-project/llvm/test/DebugInfo/X86/instcombine-fold-cast-into-phi.ll (revision 094572701dce4aaf36f4521d6cf750420d39f206)
1; RUN: opt -passes=instcombine -S %s | FileCheck %s
2
3;; Instcombine folds the trunc %x into the phi. Check it updates the phi's dbg
4;; user (otherwise the dbg use becomes poison after the original phi is
5;; deleted). Check the new phi inherits the DebugLoc.
6
7; CHECK: %[[phi:.*]] = phi i8 [ 1, %{{.*}} ], [ 0, %{{.*}} ], !dbg ![[dbg:[0-9]+]]
8; CHECK: #dbg_value(i8 %[[phi]], ![[#]], !DIExpression(DW_OP_LLVM_convert, 8, DW_ATE_signed, DW_OP_LLVM_convert, 32, DW_ATE_signed, DW_OP_stack_value)
9; CHECK: ![[dbg]] = !DILocation(line: 123,
10
11target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
12target triple = "x86_64-unknown-linux-gnu"
13
14define linkonce_odr float @f(i1 %cond) {
15entry:
16  br i1 %cond, label %if.then, label %if.end
17
18if.then:                                          ; preds = entry
19  br label %if.end
20
21if.end:                                           ; preds = %if.then, %entry
22  %p.0 = phi i32 [ 1, %if.then ], [ 0, %entry ], !dbg !13
23  call void @llvm.dbg.value(metadata i32 %p.0, metadata !4, metadata !DIExpression()), !dbg !13
24  %x = trunc i32 %p.0 to i8
25  %callff = call float @ff(i8  %x)
26  ret float %callff
27}
28
29declare void @llvm.dbg.value(metadata, metadata, metadata)
30declare float @ff(float)
31
32!llvm.dbg.cu = !{!0}
33!llvm.module.flags = !{!3}
34
35!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_11, file: !1, producer: "clang version 17.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !2, splitDebugInlining: false, nameTableKind: None)
36!1 = !DIFile(filename: "btConvexTriangleMeshShape.cpp", directory: "/")
37!2 = !{}
38!3 = !{i32 2, !"Debug Info Version", i32 3}
39!4 = !DILocalVariable(name: "p", scope: !5, file: !6, line: 2057, type: !12)
40!5 = distinct !DILexicalBlock(scope: !7, file: !6, line: 2056, column: 4)
41!6 = !DIFile(filename: "reduce.cpp", directory: "/")
42!7 = distinct !DISubprogram(name: "diagonalize", linkageName: "_ZN11btMatrix3x311diagonalizeERS_fi", scope: !8, file: !6, line: 2054, type: !9, scopeLine: 2055, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, declaration: !11, retainedNodes: !2)
43!8 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "btMatrix3x3", file: !6, line: 2050, size: 24, flags: DIFlagTypePassByValue, elements: !2, identifier: "_ZTS11btMatrix3x3")
44!9 = !DISubroutineType(types: !10)
45!10 = !{null}
46!11 = !DISubprogram(name: "diagonalize", linkageName: "_ZN11btMatrix3x311diagonalizeERS_fi", scope: !8, file: !6, line: 2054, type: !9, scopeLine: 2054, flags: DIFlagPublic | DIFlagPrototyped, spFlags: DISPFlagOptimized)
47!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
48!13 = !DILocation(line: 123, scope: !5)
49