blob: f85c9d518e9949998973474682f3d3ae95398503 [file] [log] [blame]
Adam Nemet0a77dfa2016-05-09 23:03:44 +00001; RUN: opt -loop-vectorize -force-vector-width=2 -pass-remarks-analysis=loop-vectorize < %s 2>&1 | FileCheck %s
2
3; ModuleID = '/tmp/kk.c'
4source_filename = "/tmp/kk.c"
5target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
Adam Nemet0a77dfa2016-05-09 23:03:44 +00006
7; 1 void success (char *A, char *B, char *C, char *D, char *E, int N) {
8; 2 for(int i = 0; i < N; i++) {
9; 3 A[i + 1] = A[i] + B[i];
10; 4 C[i] = D[i] * E[i];
11; 5 }
12; 6 }
13
14; CHECK: remark: /tmp/kk.c:3:16: loop not vectorized: unsafe dependent memory operations in loop. Use #pragma loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop
15
16define void @success(i8* nocapture %A, i8* nocapture readonly %B, i8* nocapture %C, i8* nocapture readonly %D, i8* nocapture readonly %E, i32 %N) !dbg !6 {
17entry:
18 %cmp28 = icmp sgt i32 %N, 0, !dbg !8
19 br i1 %cmp28, label %for.body, label %for.cond.cleanup, !dbg !9
20
21for.body: ; preds = %entry, %for.body
22 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
23 %arrayidx = getelementptr inbounds i8, i8* %A, i64 %indvars.iv, !dbg !11
24 %0 = load i8, i8* %arrayidx, align 1, !dbg !11, !tbaa !12
25 %arrayidx2 = getelementptr inbounds i8, i8* %B, i64 %indvars.iv, !dbg !15
26 %1 = load i8, i8* %arrayidx2, align 1, !dbg !15, !tbaa !12
27 %add = add i8 %1, %0, !dbg !16
28 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !9
29 %arrayidx7 = getelementptr inbounds i8, i8* %A, i64 %indvars.iv.next, !dbg !17
30 store i8 %add, i8* %arrayidx7, align 1, !dbg !18, !tbaa !12
31 %arrayidx9 = getelementptr inbounds i8, i8* %D, i64 %indvars.iv, !dbg !19
32 %2 = load i8, i8* %arrayidx9, align 1, !dbg !19, !tbaa !12
33 %arrayidx12 = getelementptr inbounds i8, i8* %E, i64 %indvars.iv, !dbg !20
34 %3 = load i8, i8* %arrayidx12, align 1, !dbg !20, !tbaa !12
35 %mul = mul i8 %3, %2, !dbg !21
36 %arrayidx16 = getelementptr inbounds i8, i8* %C, i64 %indvars.iv, !dbg !22
37 store i8 %mul, i8* %arrayidx16, align 1, !dbg !23, !tbaa !12
38 %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !9
39 %exitcond = icmp eq i32 %lftr.wideiv, %N, !dbg !9
40 br i1 %exitcond, label %for.cond.cleanup, label %for.body, !dbg !9
41
42for.cond.cleanup: ; preds = %for.body, %entry
43 ret void, !dbg !10
44}
45
46!llvm.dbg.cu = !{!0}
47!llvm.module.flags = !{!3, !4}
48!llvm.ident = !{!5}
49
50!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: NoDebug, enums: !2)
51!1 = !DIFile(filename: "/tmp/kk.c", directory: "/tmp")
52!2 = !{}
53!3 = !{i32 2, !"Debug Info Version", i32 3}
54!4 = !{i32 1, !"PIC Level", i32 2}
55!5 = !{!"clang version 3.9.0 "}
56!6 = distinct !DISubprogram(name: "success", scope: !1, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !2)
57!7 = !DISubroutineType(types: !2)
58!8 = !DILocation(line: 2, column: 20, scope: !6)
59!9 = !DILocation(line: 2, column: 3, scope: !6)
60!10 = !DILocation(line: 6, column: 1, scope: !6)
61!11 = !DILocation(line: 3, column: 16, scope: !6)
62!12 = !{!13, !13, i64 0}
63!13 = !{!"omnipotent char", !14, i64 0}
64!14 = !{!"Simple C/C++ TBAA"}
65!15 = !DILocation(line: 3, column: 23, scope: !6)
66!16 = !DILocation(line: 3, column: 21, scope: !6)
67!17 = !DILocation(line: 3, column: 5, scope: !6)
68!18 = !DILocation(line: 3, column: 14, scope: !6)
69!19 = !DILocation(line: 4, column: 12, scope: !6)
70!20 = !DILocation(line: 4, column: 19, scope: !6)
71!21 = !DILocation(line: 4, column: 17, scope: !6)
72!22 = !DILocation(line: 4, column: 5, scope: !6)
73!23 = !DILocation(line: 4, column: 10, scope: !6)