1; RUN: opt -S -loop-reduce %s | FileCheck %s 2 3;; Ensure that scev-based salvaging in LSR does not select an IV containing 4;; an 'undef' element. 5 6target triple = "x86_64-unknown-linux-gnu" 7 8define i16 @n(i1 %c1) !dbg !8 { 9entry: 10 br i1 %c1, label %m, label %for.body 11 12for.body: ; preds = %for.body, %entry 13 %iv = phi i16 [ %ivdec, %for.body ], [ 14, %entry ] 14 %ivdec = sub i16 %iv, 1 15 call void @llvm.dbg.value(metadata i16 %iv, metadata !21, metadata !DIExpression()), !dbg !19 16 br label %for.body 17 18m: ; preds = %m, %entry 19 %0 = phi i16 [ 3, %m ], [ 6, %entry ] 20 %gg = add i16 %0, 23 21 ; CHECK: call void @llvm.dbg.value(metadata i16 poison, metadata !{{[0-9]+}}, metadata !DIExpression()), 22 call void @llvm.dbg.value(metadata i16 %0, metadata !14, metadata !DIExpression()), !dbg !19 23 br label %m 24} 25 26; Function Attrs: nofree nosync nounwind readnone speculatable willreturn 27declare void @llvm.dbg.value(metadata, metadata, metadata) 28 29!llvm.dbg.cu = !{!0} 30!llvm.module.flags = !{!3, !4, !5, !6} 31!llvm.ident = !{!7} 32 33!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 14.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !2, splitDebugInlining: false, nameTableKind: None) 34!1 = !DIFile(filename: "reduced.c", directory: "/") 35!2 = !{} 36!3 = !{i32 7, !"Dwarf Version", i32 4} 37!4 = !{i32 2, !"Debug Info Version", i32 3} 38!5 = !{i32 1, !"wchar_size", i32 1} 39!6 = !{i32 7, !"frame-pointer", i32 2} 40!7 = !{!"clang version 14.0.0"} 41!8 = distinct !DISubprogram(name: "n", scope: !1, file: !1, line: 18, type: !9, scopeLine: 18, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12) 42!9 = !DISubroutineType(types: !10) 43!10 = !{!11} 44!11 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_signed) 45!12 = !{!13} 46!13 = !DILabel(scope: !8, name: "m", file: !1, line: 22) 47!14 = !DILocalVariable(name: "k", arg: 2, scope: !15, file: !1, line: 9, type: !11) 48!15 = distinct !DISubprogram(name: "i", scope: !1, file: !1, line: 9, type: !16, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !18) 49!16 = !DISubroutineType(types: !17) 50!17 = !{!11, !11, !11} 51!18 = !{!14} 52!19 = !DILocation(line: 0, scope: !15, inlinedAt: !20) 53!20 = distinct !DILocation(line: 23, scope: !8) 54!21 = !DILocalVariable(name: "x", arg: 2, scope: !15, file: !1, line: 1, type: !11) 55