1; RUN: opt -S < %s -loop-vectorize -force-vector-interleave=1 -force-vector-width=2 | FileCheck %s
2
3target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
4
5; Make sure we are preserving debug info in the vectorized code.
6
7; CHECK: for.body.lr.ph
8; CHECK:   min.iters.check = icmp ult i64 {{.*}}, 2, !dbg !{{[0-9]+}}
9; CHECK: vector.body
10; CHECK:   index {{.*}}, !dbg ![[LOC:[0-9]+]]
11; CHECK:   getelementptr inbounds i32, i32* %a, {{.*}}, !dbg ![[LOC]]
12; CHECK:   load <2 x i32>, <2 x i32>* {{.*}}, !dbg ![[LOC]]
13; CHECK:   add <2 x i32> {{.*}}, !dbg ![[LOC]]
14; CHECK:   add i64 %index, 2, !dbg ![[LOC]]
15; CHECK:   icmp eq i64 %index.next, %n.vec, !dbg ![[LOC]]
16; CHECK: middle.block
17; CHECK:   add <2 x i32> %{{.*}}, %rdx.shuf, !dbg ![[LOC]]
18; CHECK:   extractelement <2 x i32> %bin.rdx, i32 0, !dbg ![[LOC]]
19
20define i32 @f(i32* nocapture %a, i32 %size) #0 !dbg !4 {
21entry:
22  call void @llvm.dbg.value(metadata i32* %a, metadata !13, metadata !DIExpression()), !dbg !19
23  call void @llvm.dbg.value(metadata i32 %size, metadata !14, metadata !DIExpression()), !dbg !19
24  call void @llvm.dbg.value(metadata i32 0, metadata !15, metadata !DIExpression()), !dbg !20
25  call void @llvm.dbg.value(metadata i32 0, metadata !16, metadata !DIExpression()), !dbg !21
26  %cmp4 = icmp eq i32 %size, 0, !dbg !21
27  br i1 %cmp4, label %for.end, label %for.body.lr.ph, !dbg !21
28
29for.body.lr.ph:                                   ; preds = %entry
30  br label %for.body, !dbg !21
31
32for.body:                                         ; preds = %for.body.lr.ph, %for.body
33  %indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.body ]
34  %sum.05 = phi i32 [ 0, %for.body.lr.ph ], [ %add, %for.body ]
35  %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv, !dbg !22
36  %0 = load i32, i32* %arrayidx, align 4, !dbg !22
37  %add = add i32 %0, %sum.05, !dbg !22
38  %indvars.iv.next = add i64 %indvars.iv, 1, !dbg !22
39  call void @llvm.dbg.value(metadata !{null}, metadata !16, metadata !DIExpression()), !dbg !22
40  %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !22
41  %exitcond = icmp ne i32 %lftr.wideiv, %size, !dbg !22
42  br i1 %exitcond, label %for.body, label %for.cond.for.end_crit_edge, !dbg !21
43
44for.cond.for.end_crit_edge:                       ; preds = %for.body
45  %add.lcssa = phi i32 [ %add, %for.body ]
46  call void @llvm.dbg.value(metadata i32 %add.lcssa, metadata !15, metadata !DIExpression()), !dbg !22
47  br label %for.end, !dbg !21
48
49for.end:                                          ; preds = %entry, %for.cond.for.end_crit_edge
50  %sum.0.lcssa = phi i32 [ %add.lcssa, %for.cond.for.end_crit_edge ], [ 0, %entry ]
51  ret i32 %sum.0.lcssa, !dbg !26
52}
53
54; Function Attrs: nounwind readnone
55declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
56
57; Function Attrs: nounwind readnone
58declare void @llvm.dbg.value(metadata, metadata, metadata) #1
59
60attributes #0 = { nounwind readonly ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="true" "no-nans-fp-math"="true" "unsafe-fp-math"="true" "use-soft-float"="false" }
61attributes #1 = { nounwind readnone }
62
63!llvm.dbg.cu = !{!0}
64!llvm.module.flags = !{!18, !27}
65
66!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.4 (trunk 185038) (llvm/trunk 185097)", isOptimized: true, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
67!1 = !DIFile(filename: "-", directory: "/Volumes/Data/backedup/dev/os/llvm/debug")
68!2 = !{}
69!4 = distinct !DISubprogram(name: "f", line: 3, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 3, file: !5, scope: !6, type: !7, retainedNodes: !12)
70!5 = !DIFile(filename: "<stdin>", directory: "/Volumes/Data/backedup/dev/os/llvm/debug")
71!6 = !DIFile(filename: "<stdin>", directory: "/Volumes/Data/backedup/dev/os/llvm/debug")
72!7 = !DISubroutineType(types: !8)
73!8 = !{!9, !10, !11}
74!9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
75!10 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !9)
76!11 = !DIBasicType(tag: DW_TAG_base_type, name: "unsigned int", size: 32, align: 32, encoding: DW_ATE_unsigned)
77!12 = !{!13, !14, !15, !16}
78!13 = !DILocalVariable(name: "a", line: 3, arg: 1, scope: !4, file: !6, type: !10)
79!14 = !DILocalVariable(name: "size", line: 3, arg: 2, scope: !4, file: !6, type: !11)
80!15 = !DILocalVariable(name: "sum", line: 4, scope: !4, file: !6, type: !11)
81!16 = !DILocalVariable(name: "i", line: 5, scope: !17, file: !6, type: !11)
82!17 = distinct !DILexicalBlock(line: 5, column: 0, file: !5, scope: !4)
83!18 = !{i32 2, !"Dwarf Version", i32 3}
84!19 = !DILocation(line: 3, scope: !4)
85!20 = !DILocation(line: 4, scope: !4)
86!21 = !DILocation(line: 5, scope: !17)
87!22 = !DILocation(line: 6, scope: !17)
88!26 = !DILocation(line: 7, scope: !4)
89!27 = !{i32 1, !"Debug Info Version", i32 3}
90