1cee313d2SEric Christopher; RUN: opt < %s -S -loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -dce -instcombine | FileCheck %s
2cee313d2SEric Christopher; Make sure we vectorize with debugging turned on.
3cee313d2SEric Christopher
4cee313d2SEric Christophersource_filename = "test/Transforms/LoopVectorize/dbg.value.ll"
5cee313d2SEric Christophertarget 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"
6cee313d2SEric Christopher
7cee313d2SEric Christopher@A = global [1024 x i32] zeroinitializer, align 16, !dbg !0
8cee313d2SEric Christopher@B = global [1024 x i32] zeroinitializer, align 16, !dbg !7
9cee313d2SEric Christopher@C = global [1024 x i32] zeroinitializer, align 16, !dbg !9
10cee313d2SEric Christopher; CHECK-LABEL: @test(
11cee313d2SEric Christopher
12cee313d2SEric Christopher; Function Attrs: nounwind ssp uwtable
13cee313d2SEric Christopherdefine i32 @test() #0 !dbg !15 {
14cee313d2SEric Christopherentry:
15cee313d2SEric Christopher  tail call void @llvm.dbg.value(metadata i32 0, metadata !19, metadata !21), !dbg !22
16cee313d2SEric Christopher  br label %for.body, !dbg !22
17cee313d2SEric Christopher
18cee313d2SEric Christopherfor.body:                                         ; preds = %for.body, %entry
19cee313d2SEric Christopher  ;CHECK: load <4 x i32>
20cee313d2SEric Christopher  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
21cee313d2SEric Christopher  %arrayidx = getelementptr inbounds [1024 x i32], [1024 x i32]* @B, i64 0, i64 %indvars.iv, !dbg !23
22cee313d2SEric Christopher  %0 = load i32, i32* %arrayidx, align 4, !dbg !23
23cee313d2SEric Christopher  %arrayidx2 = getelementptr inbounds [1024 x i32], [1024 x i32]* @C, i64 0, i64 %indvars.iv, !dbg !23
24cee313d2SEric Christopher  %1 = load i32, i32* %arrayidx2, align 4, !dbg !23
25cee313d2SEric Christopher  %add = add nsw i32 %1, %0, !dbg !23
26cee313d2SEric Christopher  %arrayidx4 = getelementptr inbounds [1024 x i32], [1024 x i32]* @A, i64 0, i64 %indvars.iv, !dbg !23
27cee313d2SEric Christopher  store i32 %add, i32* %arrayidx4, align 4, !dbg !23
28cee313d2SEric Christopher  %indvars.iv.next = add i64 %indvars.iv, 1, !dbg !22
29cee313d2SEric Christopher  tail call void @llvm.dbg.value(metadata !12, metadata !19, metadata !21), !dbg !22
30cee313d2SEric Christopher  %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !22
31cee313d2SEric Christopher  %exitcond = icmp ne i32 %lftr.wideiv, 1024, !dbg !22
32cee313d2SEric Christopher  br i1 %exitcond, label %for.body, label %for.end, !dbg !22
33cee313d2SEric Christopher
34cee313d2SEric Christopherfor.end:                                          ; preds = %for.body
35cee313d2SEric Christopher  ret i32 0, !dbg !25
36cee313d2SEric Christopher}
37cee313d2SEric Christopher
38cee313d2SEric Christopher; Function Attrs: nounwind readnone
39cee313d2SEric Christopher
40cee313d2SEric Christopherdeclare void @llvm.dbg.declare(metadata, metadata, metadata) #1
41cee313d2SEric Christopher
42cee313d2SEric Christopher; Function Attrs: nounwind readnone
43cee313d2SEric Christopherdeclare void @llvm.dbg.value(metadata, metadata, metadata) #1
44cee313d2SEric Christopher
45*a36ddf0aSFangrui Songattributes #0 = { nounwind ssp uwtable "fp-contract-model"="standard" "frame-pointer"="non-leaf" "relocation-model"="pic" "ssp-buffers-size"="8" }
46cee313d2SEric Christopherattributes #1 = { nounwind readnone }
47cee313d2SEric Christopher
48cee313d2SEric Christopher!llvm.dbg.cu = !{!11}
49cee313d2SEric Christopher!llvm.module.flags = !{!14}
50cee313d2SEric Christopher
51cee313d2SEric Christopher!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
52cee313d2SEric Christopher!1 = !DIGlobalVariable(name: "A", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
53cee313d2SEric Christopher!2 = !DIFile(filename: "test", directory: "/path/to/somewhere")
54cee313d2SEric Christopher!3 = !DICompositeType(tag: DW_TAG_array_type, baseType: !4, size: 32768, align: 32, elements: !5)
55cee313d2SEric Christopher!4 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
56cee313d2SEric Christopher!5 = !{!6}
57cee313d2SEric Christopher!6 = !{i32 786465, i64 0, i64 1024}
58cee313d2SEric Christopher!7 = !DIGlobalVariableExpression(var: !8, expr: !DIExpression())
59cee313d2SEric Christopher!8 = !DIGlobalVariable(name: "B", scope: null, file: !2, line: 2, type: !3, isLocal: false, isDefinition: true)
60cee313d2SEric Christopher!9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression())
61cee313d2SEric Christopher!10 = !DIGlobalVariable(name: "C", scope: null, file: !2, line: 3, type: !3, isLocal: false, isDefinition: true)
62cee313d2SEric Christopher!11 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !12, retainedTypes: !12, globals: !13)
63cee313d2SEric Christopher!12 = !{}
64cee313d2SEric Christopher!13 = !{!0, !7, !9}
65cee313d2SEric Christopher!14 = !{i32 1, !"Debug Info Version", i32 3}
66cee313d2SEric Christopher!15 = distinct !DISubprogram(name: "test", linkageName: "test", scope: !2, file: !2, line: 5, type: !16, isLocal: false, isDefinition: true, scopeLine: 5, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !11, retainedNodes: !18)
67cee313d2SEric Christopher!16 = !DISubroutineType(types: !17)
68cee313d2SEric Christopher!17 = !{!4}
69cee313d2SEric Christopher!18 = !{!19}
70cee313d2SEric Christopher!19 = !DILocalVariable(name: "i", scope: !20, file: !2, line: 6, type: !4)
71cee313d2SEric Christopher!20 = distinct !DILexicalBlock(scope: !15, file: !2, line: 6)
72cee313d2SEric Christopher!21 = !DIExpression()
73cee313d2SEric Christopher!22 = !DILocation(line: 6, scope: !20)
74cee313d2SEric Christopher!23 = !DILocation(line: 7, scope: !24)
75cee313d2SEric Christopher!24 = distinct !DILexicalBlock(scope: !20, file: !2, line: 6)
76cee313d2SEric Christopher!25 = !DILocation(line: 9, scope: !15)
77cee313d2SEric Christopher
78