1; RUN: opt -loop-distribute -S < %s 2>&1 \ 2; RUN: | FileCheck %s --check-prefix=ALWAYS --check-prefix=NO_REMARKS 3; RUN: opt -loop-distribute -S -pass-remarks-missed=loop-distribute < %s 2>&1 \ 4; RUN: | FileCheck %s --check-prefix=ALWAYS --check-prefix=MISSED_REMARKS 5; RUN: opt -loop-distribute -S -pass-remarks-analysis=loop-distribute < %s 2>&1 \ 6; RUN: | FileCheck %s --check-prefix=ALWAYS --check-prefix=ANALYSIS_REMARKS 7; RUN: opt -loop-distribute -S -pass-remarks=loop-distribute < %s 2>&1 \ 8; RUN: | FileCheck %s --check-prefix=ALWAYS --check-prefix=REMARKS 9 10; This is the input program: 11; 12; 1 void forced (char *A, char *B, char *C, int N) { 13; 2 #pragma clang loop distribute(enable) 14; 3 for(int i = 0; i < N; i++) { 15; 4 A[i] = B[i] * C[i]; 16; 5 } 17; 6 } 18; 7 19; 8 void not_forced (char *A, char *B, char *C, int N) { 20; 9 for(int i = 0; i < N; i++) { 21; 10 A[i] = B[i] * C[i]; 22; 11 } 23; 12 } 24; 13 25; 14 void success (char *A, char *B, char *C, char *D, char *E, int N) { 26; 15 for(int i = 0; i < N; i++) { 27; 16 A[i + 1] = A[i] + B[i]; 28; 17 C[i] = D[i] * E[i]; 29; 18 } 30; 19 } 31 32target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 33target triple = "x86_64-apple-macosx10.11.0" 34 35; MISSED_REMARKS: remark: /tmp/t.c:3:3: loop not distributed: use -Rpass-analysis=loop-distribute for more info 36; ALWAYS: remark: /tmp/t.c:3:3: loop not distributed: memory operations are safe for vectorization 37; ALWAYS: warning: /tmp/t.c:3:3: loop not disributed: failed explicitly specified loop distribution 38 39define void @forced(i8* %A, i8* %B, i8* %C, i32 %N) !dbg !7 { 40entry: 41 %cmp12 = icmp sgt i32 %N, 0, !dbg !9 42 br i1 %cmp12, label %ph, label %for.cond.cleanup, !dbg !10 43 44ph: 45 br label %for.body 46 47for.body: 48 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %ph ] 49 %arrayidx = getelementptr inbounds i8, i8* %B, i64 %indvars.iv, !dbg !12 50 %0 = load i8, i8* %arrayidx, align 1, !dbg !12, !tbaa !13 51 %arrayidx2 = getelementptr inbounds i8, i8* %C, i64 %indvars.iv, !dbg !16 52 %1 = load i8, i8* %arrayidx2, align 1, !dbg !16, !tbaa !13 53 %mul = mul i8 %1, %0, !dbg !17 54 %arrayidx6 = getelementptr inbounds i8, i8* %A, i64 %indvars.iv, !dbg !18 55 store i8 %mul, i8* %arrayidx6, align 1, !dbg !19, !tbaa !13 56 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !10 57 %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !10 58 %exitcond = icmp eq i32 %lftr.wideiv, %N, !dbg !10 59 br i1 %exitcond, label %for.cond.cleanup, label %for.body, !dbg !10, !llvm.loop !20 60 61for.cond.cleanup: 62 ret void, !dbg !11 63} 64 65; NO_REMARKS-NOT: remark: /tmp/t.c:9:3: loop not distributed: memory operations are safe for vectorization 66; MISSED_REMARKS: remark: /tmp/t.c:9:3: loop not distributed: use -Rpass-analysis=loop-distribute for more info 67; ANALYSIS_REMARKS: remark: /tmp/t.c:9:3: loop not distributed: memory operations are safe for vectorization 68; ALWAYS-NOT: warning: /tmp/t.c:9:3: loop not disributed: failed explicitly specified loop distribution 69 70define void @not_forced(i8* %A, i8* %B, i8* %C, i32 %N) !dbg !22 { 71entry: 72 %cmp12 = icmp sgt i32 %N, 0, !dbg !23 73 br i1 %cmp12, label %ph, label %for.cond.cleanup, !dbg !24 74 75ph: 76 br label %for.body 77 78for.body: 79 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %ph ] 80 %arrayidx = getelementptr inbounds i8, i8* %B, i64 %indvars.iv, !dbg !26 81 %0 = load i8, i8* %arrayidx, align 1, !dbg !26, !tbaa !13 82 %arrayidx2 = getelementptr inbounds i8, i8* %C, i64 %indvars.iv, !dbg !27 83 %1 = load i8, i8* %arrayidx2, align 1, !dbg !27, !tbaa !13 84 %mul = mul i8 %1, %0, !dbg !28 85 %arrayidx6 = getelementptr inbounds i8, i8* %A, i64 %indvars.iv, !dbg !29 86 store i8 %mul, i8* %arrayidx6, align 1, !dbg !30, !tbaa !13 87 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !24 88 %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !24 89 %exitcond = icmp eq i32 %lftr.wideiv, %N, !dbg !24 90 br i1 %exitcond, label %for.cond.cleanup, label %for.body, !dbg !24 91 92for.cond.cleanup: 93 ret void, !dbg !25 94} 95 96; REMARKS: remark: /tmp/t.c:15:3: distributed loop 97 98define void @success(i8* %A, i8* %B, i8* %C, i8* %D, i8* %E, i32 %N) !dbg !31 { 99entry: 100 %cmp28 = icmp sgt i32 %N, 0, !dbg !32 101 br i1 %cmp28, label %ph, label %for.cond.cleanup, !dbg !33 102 103ph: 104 br label %for.body 105 106for.body: 107 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %ph ] 108 %arrayidx = getelementptr inbounds i8, i8* %A, i64 %indvars.iv, !dbg !35 109 %0 = load i8, i8* %arrayidx, align 1, !dbg !35, !tbaa !13 110 %arrayidx2 = getelementptr inbounds i8, i8* %B, i64 %indvars.iv, !dbg !36 111 %1 = load i8, i8* %arrayidx2, align 1, !dbg !36, !tbaa !13 112 %add = add i8 %1, %0, !dbg !37 113 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !33 114 %arrayidx7 = getelementptr inbounds i8, i8* %A, i64 %indvars.iv.next, !dbg !38 115 store i8 %add, i8* %arrayidx7, align 1, !dbg !39, !tbaa !13 116 %arrayidx9 = getelementptr inbounds i8, i8* %D, i64 %indvars.iv, !dbg !40 117 %2 = load i8, i8* %arrayidx9, align 1, !dbg !40, !tbaa !13 118 %arrayidx12 = getelementptr inbounds i8, i8* %E, i64 %indvars.iv, !dbg !41 119 %3 = load i8, i8* %arrayidx12, align 1, !dbg !41, !tbaa !13 120 %mul = mul i8 %3, %2, !dbg !42 121 %arrayidx16 = getelementptr inbounds i8, i8* %C, i64 %indvars.iv, !dbg !43 122 store i8 %mul, i8* %arrayidx16, align 1, !dbg !44, !tbaa !13 123 %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !33 124 %exitcond = icmp eq i32 %lftr.wideiv, %N, !dbg !33 125 br i1 %exitcond, label %for.cond.cleanup, label %for.body, !dbg !33 126 127for.cond.cleanup: 128 ret void, !dbg !34 129} 130 131!llvm.dbg.cu = !{!0} 132!llvm.module.flags = !{!3, !4} 133 134!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0 (trunk 267633) (llvm/trunk 267675)", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2) 135!1 = !DIFile(filename: "/tmp/t.c", directory: "/tmp") 136!2 = !{} 137!3 = !{i32 2, !"Dwarf Version", i32 2} 138!4 = !{i32 2, !"Debug Info Version", i32 3} 139!7 = distinct !DISubprogram(name: "forced", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !2) 140!8 = !DISubroutineType(types: !2) 141!9 = !DILocation(line: 3, column: 20, scope: !7) 142!10 = !DILocation(line: 3, column: 3, scope: !7) 143!11 = !DILocation(line: 6, column: 1, scope: !7) 144!12 = !DILocation(line: 4, column: 12, scope: !7) 145!13 = !{!14, !14, i64 0} 146!14 = !{!"omnipotent char", !15, i64 0} 147!15 = !{!"Simple C/C++ TBAA"} 148!16 = !DILocation(line: 4, column: 19, scope: !7) 149!17 = !DILocation(line: 4, column: 17, scope: !7) 150!18 = !DILocation(line: 4, column: 5, scope: !7) 151!19 = !DILocation(line: 4, column: 10, scope: !7) 152!20 = distinct !{!20, !21} 153!21 = !{!"llvm.loop.distribute.enable", i1 true} 154!22 = distinct !DISubprogram(name: "not_forced", scope: !1, file: !1, line: 8, type: !8, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !2) 155!23 = !DILocation(line: 9, column: 20, scope: !22) 156!24 = !DILocation(line: 9, column: 3, scope: !22) 157!25 = !DILocation(line: 12, column: 1, scope: !22) 158!26 = !DILocation(line: 10, column: 12, scope: !22) 159!27 = !DILocation(line: 10, column: 19, scope: !22) 160!28 = !DILocation(line: 10, column: 17, scope: !22) 161!29 = !DILocation(line: 10, column: 5, scope: !22) 162!30 = !DILocation(line: 10, column: 10, scope: !22) 163!31 = distinct !DISubprogram(name: "success", scope: !1, file: !1, line: 14, type: !8, isLocal: false, isDefinition: true, scopeLine: 14, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !2) 164!32 = !DILocation(line: 15, column: 20, scope: !31) 165!33 = !DILocation(line: 15, column: 3, scope: !31) 166!34 = !DILocation(line: 19, column: 1, scope: !31) 167!35 = !DILocation(line: 16, column: 16, scope: !31) 168!36 = !DILocation(line: 16, column: 23, scope: !31) 169!37 = !DILocation(line: 16, column: 21, scope: !31) 170!38 = !DILocation(line: 16, column: 5, scope: !31) 171!39 = !DILocation(line: 16, column: 14, scope: !31) 172!40 = !DILocation(line: 17, column: 12, scope: !31) 173!41 = !DILocation(line: 17, column: 19, scope: !31) 174!42 = !DILocation(line: 17, column: 17, scope: !31) 175!43 = !DILocation(line: 17, column: 5, scope: !31) 176!44 = !DILocation(line: 17, column: 10, scope: !31) 177