1; Confirm that the line numbers for the middle.block operations are all the
2; same as the start of the loop.
3
4; RUN: opt -S -loop-vectorize -force-vector-width=4 -force-vector-interleave=4 <%s | FileCheck %s
5;
6; CHECK: middle.block:
7; CHECK-NEXT: %{{.*}}= add <4 x i32>{{.*}}, !dbg ![[DL:[0-9]+]]
8; CHECK-NEXT: %{{.*}}= add <4 x i32>{{.*}}, !dbg ![[DL]]
9; CHECK-NEXT: %{{.*}}= add <4 x i32>{{.*}}, !dbg ![[DL]]
10; CHECK-NEXT: %{{.*}}= call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> {{.*}}), !dbg ![[DL]]
11; CHECK-NEXT: %{{.*}}= icmp eq i64{{.*}}, !dbg ![[DL]]
12; CHECK-NEXT: br i1 %{{.*}}, !dbg ![[DL]]
13; CHECK: ![[DL]] = !DILocation(line: 5,
14
15; This IR can be generated by running:
16; clang -gmlt -S src.cpp -emit-llvm -mllvm -opt-bisect-limit=56 -O2 -o -
17;
18; Where  src.cpp contains:
19; int foo(int count, int *bar)
20; {
21;   int ret = count;
22;   int tmp;
23;   for (int j = 0; j < count; j++) {
24;     tmp = bar[j];
25;     ret += tmp;
26;   }
27;
28;   return ret;
29; }
30
31define dso_local i32 @"foo"(i32 %count, i32* nocapture readonly %bar) local_unnamed_addr !dbg !8 {
32entry:
33  %cmp8 = icmp sgt i32 %count, 0, !dbg !10
34  br i1 %cmp8, label %for.body.preheader, label %for.cond.cleanup, !dbg !10
35
36for.body.preheader:                               ; preds = %entry
37  %wide.trip.count = zext i32 %count to i64
38  br label %for.body, !dbg !11
39
40for.cond.cleanup.loopexit:                        ; preds = %for.body
41  %add.lcssa = phi i32 [ %add, %for.body ], !dbg !12
42  br label %for.cond.cleanup, !dbg !13
43
44for.cond.cleanup:                                 ; preds = %for.cond.cleanup.loopexit, %entry
45  %ret.0.lcssa = phi i32 [ %count, %entry ], [ %add.lcssa, %for.cond.cleanup.loopexit ], !dbg !14
46  ret i32 %ret.0.lcssa, !dbg !13
47
48for.body:                                         ; preds = %for.body, %for.body.preheader
49  %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
50  %ret.09 = phi i32 [ %count, %for.body.preheader ], [ %add, %for.body ]
51  %arrayidx = getelementptr inbounds i32, i32* %bar, i64 %indvars.iv, !dbg !11
52  %0 = load i32, i32* %arrayidx, align 4, !dbg !11, !tbaa !15
53  %add = add nsw i32 %0, %ret.09, !dbg !12
54  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !10
55  %exitcond = icmp eq i64 %indvars.iv.next, %wide.trip.count, !dbg !10
56  br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body, !dbg !10, !llvm.loop !19
57}
58
59!llvm.dbg.cu = !{!0}
60!llvm.module.flags = !{!3, !4, !5, !6}
61!llvm.ident = !{!7}
62
63!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2, nameTableKind: None)
64!1 = !DIFile(filename: "src.cpp", directory: "")
65!2 = !{}
66!3 = !{i32 2, !"CodeView", i32 1}
67!4 = !{i32 2, !"Debug Info Version", i32 3}
68!5 = !{i32 1, !"wchar_size", i32 2}
69!6 = !{i32 7, !"PIC Level", i32 2}
70!7 = !{!""}
71!8 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !9, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
72!9 = !DISubroutineType(types: !2)
73!10 = !DILocation(line: 5, scope: !8)
74!11 = !DILocation(line: 6, scope: !8)
75!12 = !DILocation(line: 7, scope: !8)
76!13 = !DILocation(line: 10, scope: !8)
77!14 = !DILocation(line: 0, scope: !8)
78!15 = !{!16, !16, i64 0}
79!16 = !{!"int", !17, i64 0}
80!17 = !{!"omnipotent char", !18, i64 0}
81!18 = !{!"Simple C++ TBAA"}
82!19 = distinct !{!19, !10, !20}
83!20 = !DILocation(line: 8, scope: !8)
84