1; RUN: opt -S -loop-vectorize -pass-remarks-analysis=loop-vectorize -pass-remarks-with-hotness < %s 2>&1 | FileCheck %s 2; RUN: opt -S -passes=loop-vectorize -pass-remarks-analysis=loop-vectorize -pass-remarks-with-hotness < %s 2>&1 | FileCheck %s 3 4; 1 void cold(char *A, char *B, char *C, char *D, char *E, int N) { 5; 2 for(int i = 0; i < N; i++) { 6; 3 A[i + 1] = A[i] + B[i]; 7; 4 C[i] = D[i] * E[i]; 8; 5 } 9; 6 } 10; 7 11; 8 void hot(char *A, char *B, char *C, char *D, char *E, int N) { 12; 9 for(int i = 0; i < N; i++) { 13; 10 A[i + 1] = A[i] + B[i]; 14; 11 C[i] = D[i] * E[i]; 15; 12 } 16; 13 } 17; 14 18; 15 void unknown(char *A, char *B, char *C, char *D, char *E, int N) { 19; 16 for(int i = 0; i < N; i++) { 20; 17 A[i + 1] = A[i] + B[i]; 21; 18 C[i] = D[i] * E[i]; 22; 19 } 23; 20 } 24 25; CHECK: remark: /tmp/s.c:2:3: 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 (hotness: 300) 26; CHECK: remark: /tmp/s.c:9:3: 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 (hotness: 5000) 27; CHECK: remark: /tmp/s.c:16:3: 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{{$}} 28 29; ModuleID = '/tmp/s.c' 30source_filename = "/tmp/s.c" 31target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 32 33; Function Attrs: norecurse nounwind ssp uwtable 34define void @cold(i8* nocapture %A, i8* nocapture readonly %B, i8* nocapture %C, i8* nocapture readonly %D, i8* nocapture readonly %E, i32 %N) local_unnamed_addr #0 !dbg !7 !prof !56 { 35entry: 36 %cmp28 = icmp sgt i32 %N, 0, !dbg !9 37 br i1 %cmp28, label %ph, label %for.cond.cleanup, !dbg !10, !prof !58 38 39ph: 40 br label %for.body 41 42for.body: 43 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %ph ] 44 %arrayidx = getelementptr inbounds i8, i8* %A, i64 %indvars.iv, !dbg !12 45 %0 = load i8, i8* %arrayidx, align 1, !dbg !12, !tbaa !13 46 %arrayidx2 = getelementptr inbounds i8, i8* %B, i64 %indvars.iv, !dbg !16 47 %1 = load i8, i8* %arrayidx2, align 1, !dbg !16, !tbaa !13 48 %add = add i8 %1, %0, !dbg !17 49 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !10 50 %arrayidx7 = getelementptr inbounds i8, i8* %A, i64 %indvars.iv.next, !dbg !18 51 store i8 %add, i8* %arrayidx7, align 1, !dbg !19, !tbaa !13 52 %arrayidx9 = getelementptr inbounds i8, i8* %D, i64 %indvars.iv, !dbg !20 53 %2 = load i8, i8* %arrayidx9, align 1, !dbg !20, !tbaa !13 54 %arrayidx12 = getelementptr inbounds i8, i8* %E, i64 %indvars.iv, !dbg !21 55 %3 = load i8, i8* %arrayidx12, align 1, !dbg !21, !tbaa !13 56 %mul = mul i8 %3, %2, !dbg !22 57 %arrayidx16 = getelementptr inbounds i8, i8* %C, i64 %indvars.iv, !dbg !23 58 store i8 %mul, i8* %arrayidx16, align 1, !dbg !24, !tbaa !13 59 %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !10 60 %exitcond = icmp eq i32 %lftr.wideiv, %N, !dbg !10 61 br i1 %exitcond, label %for.cond.cleanup, label %for.body, !dbg !10, !llvm.loop !25, !prof !59 62 63for.cond.cleanup: 64 ret void, !dbg !11 65} 66 67; Function Attrs: norecurse nounwind ssp uwtable 68define void @hot(i8* nocapture %A, i8* nocapture readonly %B, i8* nocapture %C, i8* nocapture readonly %D, i8* nocapture readonly %E, i32 %N) local_unnamed_addr #0 !dbg !26 !prof !57 { 69entry: 70 %cmp28 = icmp sgt i32 %N, 0, !dbg !27 71 br i1 %cmp28, label %ph, label %for.cond.cleanup, !dbg !28, !prof !58 72 73ph: 74 br label %for.body 75 76for.body: 77 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %ph ] 78 %arrayidx = getelementptr inbounds i8, i8* %A, i64 %indvars.iv, !dbg !30 79 %0 = load i8, i8* %arrayidx, align 1, !dbg !30, !tbaa !13 80 %arrayidx2 = getelementptr inbounds i8, i8* %B, i64 %indvars.iv, !dbg !31 81 %1 = load i8, i8* %arrayidx2, align 1, !dbg !31, !tbaa !13 82 %add = add i8 %1, %0, !dbg !32 83 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !28 84 %arrayidx7 = getelementptr inbounds i8, i8* %A, i64 %indvars.iv.next, !dbg !33 85 store i8 %add, i8* %arrayidx7, align 1, !dbg !34, !tbaa !13 86 %arrayidx9 = getelementptr inbounds i8, i8* %D, i64 %indvars.iv, !dbg !35 87 %2 = load i8, i8* %arrayidx9, align 1, !dbg !35, !tbaa !13 88 %arrayidx12 = getelementptr inbounds i8, i8* %E, i64 %indvars.iv, !dbg !36 89 %3 = load i8, i8* %arrayidx12, align 1, !dbg !36, !tbaa !13 90 %mul = mul i8 %3, %2, !dbg !37 91 %arrayidx16 = getelementptr inbounds i8, i8* %C, i64 %indvars.iv, !dbg !38 92 store i8 %mul, i8* %arrayidx16, align 1, !dbg !39, !tbaa !13 93 %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !28 94 %exitcond = icmp eq i32 %lftr.wideiv, %N, !dbg !28 95 br i1 %exitcond, label %for.cond.cleanup, label %for.body, !dbg !28, !llvm.loop !40, !prof !59 96 97for.cond.cleanup: 98 ret void, !dbg !29 99} 100 101; Function Attrs: norecurse nounwind ssp uwtable 102define void @unknown(i8* nocapture %A, i8* nocapture readonly %B, i8* nocapture %C, i8* nocapture readonly %D, i8* nocapture readonly %E, i32 %N) local_unnamed_addr #0 !dbg !41 { 103entry: 104 %cmp28 = icmp sgt i32 %N, 0, !dbg !42 105 br i1 %cmp28, label %ph, label %for.cond.cleanup, !dbg !43 106 107ph: 108 br label %for.body 109 110for.body: 111 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %ph ] 112 %arrayidx = getelementptr inbounds i8, i8* %A, i64 %indvars.iv, !dbg !45 113 %0 = load i8, i8* %arrayidx, align 1, !dbg !45, !tbaa !13 114 %arrayidx2 = getelementptr inbounds i8, i8* %B, i64 %indvars.iv, !dbg !46 115 %1 = load i8, i8* %arrayidx2, align 1, !dbg !46, !tbaa !13 116 %add = add i8 %1, %0, !dbg !47 117 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !43 118 %arrayidx7 = getelementptr inbounds i8, i8* %A, i64 %indvars.iv.next, !dbg !48 119 store i8 %add, i8* %arrayidx7, align 1, !dbg !49, !tbaa !13 120 %arrayidx9 = getelementptr inbounds i8, i8* %D, i64 %indvars.iv, !dbg !50 121 %2 = load i8, i8* %arrayidx9, align 1, !dbg !50, !tbaa !13 122 %arrayidx12 = getelementptr inbounds i8, i8* %E, i64 %indvars.iv, !dbg !51 123 %3 = load i8, i8* %arrayidx12, align 1, !dbg !51, !tbaa !13 124 %mul = mul i8 %3, %2, !dbg !52 125 %arrayidx16 = getelementptr inbounds i8, i8* %C, i64 %indvars.iv, !dbg !53 126 store i8 %mul, i8* %arrayidx16, align 1, !dbg !54, !tbaa !13 127 %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !43 128 %exitcond = icmp eq i32 %lftr.wideiv, %N, !dbg !43 129 br i1 %exitcond, label %for.cond.cleanup, label %for.body, !dbg !43, !llvm.loop !55 130 131for.cond.cleanup: 132 ret void, !dbg !44 133} 134 135attributes #0 = { norecurse nounwind ssp uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="core2" "target-features"="+cx16,+fxsr,+mmx,+sse,+sse2,+sse3,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } 136 137!llvm.dbg.cu = !{!0} 138!llvm.module.flags = !{!3, !4, !5} 139!llvm.ident = !{!6} 140 141!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0 (trunk 273572) (llvm/trunk 273585)", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2) 142!1 = !DIFile(filename: "/tmp/s.c", directory: "/tmp") 143!2 = !{} 144!3 = !{i32 2, !"Dwarf Version", i32 2} 145!4 = !{i32 2, !"Debug Info Version", i32 3} 146!5 = !{i32 1, !"PIC Level", i32 2} 147!6 = !{!"clang version 3.9.0 (trunk 273572) (llvm/trunk 273585)"} 148!7 = distinct !DISubprogram(name: "cold", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2) 149!8 = !DISubroutineType(types: !2) 150!9 = !DILocation(line: 2, column: 20, scope: !7) 151!10 = !DILocation(line: 2, column: 3, scope: !7) 152!11 = !DILocation(line: 6, column: 1, scope: !7) 153!12 = !DILocation(line: 3, column: 16, scope: !7) 154!13 = !{!14, !14, i64 0} 155!14 = !{!"omnipotent char", !15, i64 0} 156!15 = !{!"Simple C/C++ TBAA"} 157!16 = !DILocation(line: 3, column: 23, scope: !7) 158!17 = !DILocation(line: 3, column: 21, scope: !7) 159!18 = !DILocation(line: 3, column: 5, scope: !7) 160!19 = !DILocation(line: 3, column: 14, scope: !7) 161!20 = !DILocation(line: 4, column: 12, scope: !7) 162!21 = !DILocation(line: 4, column: 19, scope: !7) 163!22 = !DILocation(line: 4, column: 17, scope: !7) 164!23 = !DILocation(line: 4, column: 5, scope: !7) 165!24 = !DILocation(line: 4, column: 10, scope: !7) 166!25 = distinct !{!25, !10} 167!26 = distinct !DISubprogram(name: "hot", scope: !1, file: !1, line: 8, type: !8, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2) 168!27 = !DILocation(line: 9, column: 20, scope: !26) 169!28 = !DILocation(line: 9, column: 3, scope: !26) 170!29 = !DILocation(line: 13, column: 1, scope: !26) 171!30 = !DILocation(line: 10, column: 16, scope: !26) 172!31 = !DILocation(line: 10, column: 23, scope: !26) 173!32 = !DILocation(line: 10, column: 21, scope: !26) 174!33 = !DILocation(line: 10, column: 5, scope: !26) 175!34 = !DILocation(line: 10, column: 14, scope: !26) 176!35 = !DILocation(line: 11, column: 12, scope: !26) 177!36 = !DILocation(line: 11, column: 19, scope: !26) 178!37 = !DILocation(line: 11, column: 17, scope: !26) 179!38 = !DILocation(line: 11, column: 5, scope: !26) 180!39 = !DILocation(line: 11, column: 10, scope: !26) 181!40 = distinct !{!40, !28} 182!41 = distinct !DISubprogram(name: "unknown", scope: !1, file: !1, line: 15, type: !8, isLocal: false, isDefinition: true, scopeLine: 15, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2) 183!42 = !DILocation(line: 16, column: 20, scope: !41) 184!43 = !DILocation(line: 16, column: 3, scope: !41) 185!44 = !DILocation(line: 20, column: 1, scope: !41) 186!45 = !DILocation(line: 17, column: 16, scope: !41) 187!46 = !DILocation(line: 17, column: 23, scope: !41) 188!47 = !DILocation(line: 17, column: 21, scope: !41) 189!48 = !DILocation(line: 17, column: 5, scope: !41) 190!49 = !DILocation(line: 17, column: 14, scope: !41) 191!50 = !DILocation(line: 18, column: 12, scope: !41) 192!51 = !DILocation(line: 18, column: 19, scope: !41) 193!52 = !DILocation(line: 18, column: 17, scope: !41) 194!53 = !DILocation(line: 18, column: 5, scope: !41) 195!54 = !DILocation(line: 18, column: 10, scope: !41) 196!55 = distinct !{!55, !43} 197!56 = !{!"function_entry_count", i64 3} 198!57 = !{!"function_entry_count", i64 50} 199!58 = !{!"branch_weights", i32 99, i32 1} 200!59 = !{!"branch_weights", i32 1, i32 99} 201