1; RUN: opt -passes=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" 6 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] = Dptr E[i]; 11; 5 } 12; 6 } 13 14; CHECK: remark: /tmp/kk.c:3:14: loop not vectorized: unsafe dependent memory operations in loop. Use #pragma clang loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop 15 16define void @success(ptr nocapture %A, ptr nocapture readonly %B, ptr nocapture %C, ptr nocapture readonly %D, ptr 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, ptr %A, i64 %indvars.iv, !dbg !11 24 %0 = load i8, ptr %arrayidx, align 1, !dbg !11, !tbaa !12 25 %arrayidx2 = getelementptr inbounds i8, ptr %B, i64 %indvars.iv, !dbg !15 26 %1 = load i8, ptr %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, ptr %A, i64 %indvars.iv.next, !dbg !17 30 store i8 %add, ptr %arrayidx7, align 1, !dbg !18, !tbaa !12 31 %arrayidx9 = getelementptr inbounds i8, ptr %D, i64 %indvars.iv, !dbg !19 32 %2 = load i8, ptr %arrayidx9, align 1, !dbg !19, !tbaa !12 33 %arrayidx12 = getelementptr inbounds i8, ptr %E, i64 %indvars.iv, !dbg !20 34 %3 = load i8, ptr %arrayidx12, align 1, !dbg !20, !tbaa !12 35 %mul = mul i8 %3, %2, !dbg !21 36 %arrayidx16 = getelementptr inbounds i8, ptr %C, i64 %indvars.iv, !dbg !22 37 store i8 %mul, ptr %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, retainedNodes: !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) 74