1 ; RUN: llc -mtriple=x86_64-pc-linux -x86-cmov-converter=true -verify-machineinstrs < %s | FileCheck %s
3 ; Test for PR34565, check that DBG instructions are ignored while optimizing
4 ; X86 CMOV instructions.
5 ; In this case, we check that there is no 'cmov' generated.
9 @main.buf = private unnamed_addr constant [10 x i64] [i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9], align 8
11 define i32 @main() #0 !dbg !5 {
15 while.body: ; preds = %while.body, %entry
16 %a.010 = phi i32 [ 0, %entry ], [ %add.a.0, %while.body ]
17 %b.09 = phi i32 [ 10, %entry ], [ %b.0.add, %while.body ]
18 %add = add i32 %a.010, %b.09
19 %call = tail call i32 @rand()
20 %conv = sext i32 %call to i64
21 %arrayidx = getelementptr inbounds [10 x i64], ptr @main.buf, i32 0, i32 %add
22 %0 = load i64, ptr %arrayidx, align 8
23 %cmp1 = icmp ult i64 %0, %conv
24 %b.0.add = select i1 %cmp1, i32 %b.09, i32 %add
25 %add.a.0 = select i1 %cmp1, i32 %add, i32 %a.010
26 tail call void @llvm.dbg.value(metadata i32 %add.a.0, metadata !10, metadata !DIExpression()), !dbg !13
27 tail call void @llvm.dbg.value(metadata i32 %b.0.add, metadata !12, metadata !DIExpression()), !dbg !14
28 tail call void @llvm.dbg.value(metadata i32 %add.a.0, metadata !10, metadata !DIExpression()), !dbg !13
29 tail call void @llvm.dbg.value(metadata i32 %b.0.add, metadata !12, metadata !DIExpression()), !dbg !14
30 %cmp = icmp ult i32 %add.a.0, %b.0.add
31 br i1 %cmp, label %while.body, label %while.end
33 while.end: ; preds = %while.body
39 declare void @llvm.dbg.value(metadata, metadata, metadata)
41 attributes #0 = { "target-cpu"="x86-64" }
44 !llvm.module.flags = !{!3, !4}
46 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 (trunk)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
47 !1 = !DIFile(filename: "PR34565.c", directory: "\5C")
49 !3 = !{i32 2, !"Dwarf Version", i32 4}
50 !4 = !{i32 2, !"Debug Info Version", i32 3}
51 !5 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 3, type: !6, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !9)
52 !6 = !DISubroutineType(types: !7)
54 !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
56 !10 = !DILocalVariable(name: "a", scope: !5, file: !1, line: 6, type: !11)
57 !11 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
58 !12 = !DILocalVariable(name: "b", scope: !5, file: !1, line: 7, type: !11)
59 !13 = !DILocation(line: 6, column: 16, scope: !5)
60 !14 = !DILocation(line: 7, column: 16, scope: !5)