1; 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" 6target triple = "x86_64-apple-macosx10.11.0" 7 8; 1 void success (char *A, char *B, char *C, char *D, char *E, int N) { 9; 2 for(int i = 0; i < N; i++) { 10; 3 A[i + 1] = A[i] + B[i]; 11; 4 C[i] = D[i] * E[i]; 12; 5 } 13; 6 } 14 15; 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 16 17define void @success(i8* nocapture %A, i8* nocapture readonly %B, i8* nocapture %C, i8* nocapture readonly %D, i8* nocapture readonly %E, i32 %N) !dbg !6 { 18entry: 19 %cmp28 = icmp sgt i32 %N, 0, !dbg !8 20 br i1 %cmp28, label %for.body, label %for.cond.cleanup, !dbg !9 21 22for.body: ; preds = %entry, %for.body 23 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ] 24 %arrayidx = getelementptr inbounds i8, i8* %A, i64 %indvars.iv, !dbg !11 25 %0 = load i8, i8* %arrayidx, align 1, !dbg !11, !tbaa !12 26 %arrayidx2 = getelementptr inbounds i8, i8* %B, i64 %indvars.iv, !dbg !15 27 %1 = load i8, i8* %arrayidx2, align 1, !dbg !15, !tbaa !12 28 %add = add i8 %1, %0, !dbg !16 29 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !9 30 %arrayidx7 = getelementptr inbounds i8, i8* %A, i64 %indvars.iv.next, !dbg !17 31 store i8 %add, i8* %arrayidx7, align 1, !dbg !18, !tbaa !12 32 %arrayidx9 = getelementptr inbounds i8, i8* %D, i64 %indvars.iv, !dbg !19 33 %2 = load i8, i8* %arrayidx9, align 1, !dbg !19, !tbaa !12 34 %arrayidx12 = getelementptr inbounds i8, i8* %E, i64 %indvars.iv, !dbg !20 35 %3 = load i8, i8* %arrayidx12, align 1, !dbg !20, !tbaa !12 36 %mul = mul i8 %3, %2, !dbg !21 37 %arrayidx16 = getelementptr inbounds i8, i8* %C, i64 %indvars.iv, !dbg !22 38 store i8 %mul, i8* %arrayidx16, align 1, !dbg !23, !tbaa !12 39 %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !9 40 %exitcond = icmp eq i32 %lftr.wideiv, %N, !dbg !9 41 br i1 %exitcond, label %for.cond.cleanup, label %for.body, !dbg !9 42 43for.cond.cleanup: ; preds = %for.body, %entry 44 ret void, !dbg !10 45} 46 47!llvm.dbg.cu = !{!0} 48!llvm.module.flags = !{!3, !4} 49!llvm.ident = !{!5} 50 51!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: NoDebug, enums: !2) 52!1 = !DIFile(filename: "/tmp/kk.c", directory: "/tmp") 53!2 = !{} 54!3 = !{i32 2, !"Debug Info Version", i32 3} 55!4 = !{i32 1, !"PIC Level", i32 2} 56!5 = !{!"clang version 3.9.0 "} 57!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) 58!7 = !DISubroutineType(types: !2) 59!8 = !DILocation(line: 2, column: 20, scope: !6) 60!9 = !DILocation(line: 2, column: 3, scope: !6) 61!10 = !DILocation(line: 6, column: 1, scope: !6) 62!11 = !DILocation(line: 3, column: 16, scope: !6) 63!12 = !{!13, !13, i64 0} 64!13 = !{!"omnipotent char", !14, i64 0} 65!14 = !{!"Simple C/C++ TBAA"} 66!15 = !DILocation(line: 3, column: 23, scope: !6) 67!16 = !DILocation(line: 3, column: 21, scope: !6) 68!17 = !DILocation(line: 3, column: 5, scope: !6) 69!18 = !DILocation(line: 3, column: 14, scope: !6) 70!19 = !DILocation(line: 4, column: 12, scope: !6) 71!20 = !DILocation(line: 4, column: 19, scope: !6) 72!21 = !DILocation(line: 4, column: 17, scope: !6) 73!22 = !DILocation(line: 4, column: 5, scope: !6) 74!23 = !DILocation(line: 4, column: 10, scope: !6) 75