1; RUN: opt < %s -loop-vectorize -mtriple=x86_64-unknown-linux -S -pass-remarks='loop-vectorize' 2>&1 | FileCheck -check-prefix=VECTORIZED %s
2; RUN: opt < %s -loop-vectorize -force-vector-width=1 -force-vector-interleave=4 -mtriple=x86_64-unknown-linux -S -pass-remarks='loop-vectorize' 2>&1 | FileCheck -check-prefix=UNROLLED %s
3; RUN: opt < %s -loop-vectorize -force-vector-width=1 -force-vector-interleave=1 -mtriple=x86_64-unknown-linux -S -pass-remarks-analysis='loop-vectorize' 2>&1 | FileCheck -check-prefix=NONE %s
4
5; RUN: llc < %s -mtriple x86_64-pc-linux-gnu -o - | FileCheck -check-prefix=DEBUG-OUTPUT %s
6; DEBUG-OUTPUT-NOT: .loc
7; DEBUG-OUTPUT-NOT: {{.*}}.debug_info
8
9; VECTORIZED: remark: vectorization-remarks.c:17:8: vectorized loop (vectorization width: 4, interleaved count: 1)
10; UNROLLED: remark: vectorization-remarks.c:17:8: interleaved loop (interleaved count: 4)
11; NONE: remark: vectorization-remarks.c:17:8: loop not vectorized: vectorization and interleaving are explicitly disabled, or vectorize width and interleave count are both set to 1
12
13target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
14
15define i32 @foo(i32 %n) #0 !dbg !4 {
16entry:
17  %diff = alloca i32, align 4
18  %cb = alloca [16 x i8], align 16
19  %cc = alloca [16 x i8], align 16
20  store i32 0, i32* %diff, align 4, !dbg !10, !tbaa !11
21  br label %for.body, !dbg !15
22
23for.body:                                         ; preds = %for.body, %entry
24  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
25  %add8 = phi i32 [ 0, %entry ], [ %add, %for.body ], !dbg !19
26  %arrayidx = getelementptr inbounds [16 x i8], [16 x i8]* %cb, i64 0, i64 %indvars.iv, !dbg !19
27  %0 = load i8, i8* %arrayidx, align 1, !dbg !19, !tbaa !21
28  %conv = sext i8 %0 to i32, !dbg !19
29  %arrayidx2 = getelementptr inbounds [16 x i8], [16 x i8]* %cc, i64 0, i64 %indvars.iv, !dbg !19
30  %1 = load i8, i8* %arrayidx2, align 1, !dbg !19, !tbaa !21
31  %conv3 = sext i8 %1 to i32, !dbg !19
32  %sub = sub i32 %conv, %conv3, !dbg !19
33  %add = add nsw i32 %sub, %add8, !dbg !19
34  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !15
35  %exitcond = icmp eq i64 %indvars.iv.next, 16, !dbg !15
36  br i1 %exitcond, label %for.end, label %for.body, !dbg !15
37
38for.end:                                          ; preds = %for.body
39  store i32 %add, i32* %diff, align 4, !dbg !19, !tbaa !11
40  call void @ibar(i32* %diff) #2, !dbg !22
41  ret i32 0, !dbg !23
42}
43
44declare void @ibar(i32*) #1
45
46!llvm.module.flags = !{!7, !8}
47!llvm.ident = !{!9}
48!llvm.dbg.cu = !{!24}
49
50!1 = !DIFile(filename: "vectorization-remarks.c", directory: ".")
51!2 = !{}
52!3 = !{!4}
53!4 = distinct !DISubprogram(name: "foo", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !24, scopeLine: 6, file: !1, scope: !5, type: !6, variables: !2)
54!5 = !DIFile(filename: "vectorization-remarks.c", directory: ".")
55!6 = !DISubroutineType(types: !2)
56!7 = !{i32 2, !"Dwarf Version", i32 4}
57!8 = !{i32 1, !"Debug Info Version", i32 3}
58!9 = !{!"clang version 3.5.0 "}
59!10 = !DILocation(line: 8, column: 3, scope: !4)
60!11 = !{!12, !12, i64 0}
61!12 = !{!"int", !13, i64 0}
62!13 = !{!"omnipotent char", !14, i64 0}
63!14 = !{!"Simple C/C++ TBAA"}
64!15 = !DILocation(line: 17, column: 8, scope: !16)
65!16 = distinct !DILexicalBlock(line: 17, column: 8, file: !1, scope: !17)
66!17 = distinct !DILexicalBlock(line: 17, column: 8, file: !1, scope: !18)
67!18 = distinct !DILexicalBlock(line: 17, column: 3, file: !1, scope: !4)
68!19 = !DILocation(line: 18, column: 5, scope: !20)
69!20 = distinct !DILexicalBlock(line: 17, column: 27, file: !1, scope: !18)
70!21 = !{!13, !13, i64 0}
71!22 = !DILocation(line: 20, column: 3, scope: !4)
72!23 = !DILocation(line: 21, column: 3, scope: !4)
73!24 = distinct !DICompileUnit(language: DW_LANG_C89, file: !1, emissionKind: NoDebug)
74