1 ; RUN: opt -S -loop-vectorize -pass-remarks-missed=loop-vectorize \
2 ; RUN: -pass-remarks-with-hotness < %s 2>&1 | \
3 ; RUN: FileCheck -check-prefix=HOTNESS -check-prefix=BOTH %s
5 ; RUN: opt -S -loop-vectorize -pass-remarks-missed=loop-vectorize < %s 2>&1 | \
6 ; RUN: FileCheck -check-prefix=NO_HOTNESS -check-prefix=BOTH %s
9 ; RUN: opt -S -passes=loop-vectorize -pass-remarks-missed=loop-vectorize \
10 ; RUN: -pass-remarks-with-hotness < %s 2>&1 | \
11 ; RUN: FileCheck -check-prefix=HOTNESS -check-prefix=BOTH %s
13 ; RUN: opt -S -passes=loop-vectorize \
14 ; RUN: -pass-remarks-missed=loop-vectorize < %s 2>&1 | \
15 ; RUN: FileCheck -check-prefix=NO_HOTNESS -check-prefix=BOTH %s
18 ; 1 void cold(char *A, char *B, char *C, char *D, char *E, int N) {
19 ; 2 for(int i = 0; i < N; i++) {
20 ; 3 A[i + 1] = A[i] + B[i];
21 ; 4 C[i] = D[i] * E[i];
25 ; 8 void hot(char *A, char *B, char *C, char *D, char *E, int N) {
26 ; 9 for(int i = 0; i < N; i++) {
27 ; 10 A[i + 1] = A[i] + B[i];
28 ; 11 C[i] = D[i] * E[i];
32 ; 15 void unknown(char *A, char *B, char *C, char *D, char *E, int N) {
33 ; 16 for(int i = 0; i < N; i++) {
34 ; 17 A[i + 1] = A[i] + B[i];
35 ; 18 C[i] = D[i] * E[i];
39 ; HOTNESS: remark: /tmp/s.c:2:3: loop not vectorized (hotness: 300)
40 ; NO_HOTNESS: remark: /tmp/s.c:2:3: loop not vectorized{{$}}
41 ; HOTNESS: remark: /tmp/s.c:9:3: loop not vectorized (hotness: 5000)
42 ; NO_HOTNESS: remark: /tmp/s.c:9:3: loop not vectorized{{$}}
43 ; BOTH: remark: /tmp/s.c:16:3: loop not vectorized{{$}}
45 ; ModuleID = '/tmp/s.c'
46 source_filename = "/tmp/s.c"
47 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
49 ; Function Attrs: norecurse nounwind ssp uwtable
50 define 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 {
52 %cmp28 = icmp sgt i32 %N, 0, !dbg !9
53 br i1 %cmp28, label %ph, label %for.cond.cleanup, !dbg !10, !prof !58
59 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %ph ]
60 %arrayidx = getelementptr inbounds i8, i8* %A, i64 %indvars.iv, !dbg !12
61 %0 = load i8, i8* %arrayidx, align 1, !dbg !12, !tbaa !13
62 %arrayidx2 = getelementptr inbounds i8, i8* %B, i64 %indvars.iv, !dbg !16
63 %1 = load i8, i8* %arrayidx2, align 1, !dbg !16, !tbaa !13
64 %add = add i8 %1, %0, !dbg !17
65 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !10
66 %arrayidx7 = getelementptr inbounds i8, i8* %A, i64 %indvars.iv.next, !dbg !18
67 store i8 %add, i8* %arrayidx7, align 1, !dbg !19, !tbaa !13
68 %arrayidx9 = getelementptr inbounds i8, i8* %D, i64 %indvars.iv, !dbg !20
69 %2 = load i8, i8* %arrayidx9, align 1, !dbg !20, !tbaa !13
70 %arrayidx12 = getelementptr inbounds i8, i8* %E, i64 %indvars.iv, !dbg !21
71 %3 = load i8, i8* %arrayidx12, align 1, !dbg !21, !tbaa !13
72 %mul = mul i8 %3, %2, !dbg !22
73 %arrayidx16 = getelementptr inbounds i8, i8* %C, i64 %indvars.iv, !dbg !23
74 store i8 %mul, i8* %arrayidx16, align 1, !dbg !24, !tbaa !13
75 %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !10
76 %exitcond = icmp eq i32 %lftr.wideiv, %N, !dbg !10
77 br i1 %exitcond, label %for.cond.cleanup, label %for.body, !dbg !10, !llvm.loop !25, !prof !59
83 ; Function Attrs: norecurse nounwind ssp uwtable
84 define 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 {
86 %cmp28 = icmp sgt i32 %N, 0, !dbg !27
87 br i1 %cmp28, label %ph, label %for.cond.cleanup, !dbg !28, !prof !58
93 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %ph ]
94 %arrayidx = getelementptr inbounds i8, i8* %A, i64 %indvars.iv, !dbg !30
95 %0 = load i8, i8* %arrayidx, align 1, !dbg !30, !tbaa !13
96 %arrayidx2 = getelementptr inbounds i8, i8* %B, i64 %indvars.iv, !dbg !31
97 %1 = load i8, i8* %arrayidx2, align 1, !dbg !31, !tbaa !13
98 %add = add i8 %1, %0, !dbg !32
99 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !28
100 %arrayidx7 = getelementptr inbounds i8, i8* %A, i64 %indvars.iv.next, !dbg !33
101 store i8 %add, i8* %arrayidx7, align 1, !dbg !34, !tbaa !13
102 %arrayidx9 = getelementptr inbounds i8, i8* %D, i64 %indvars.iv, !dbg !35
103 %2 = load i8, i8* %arrayidx9, align 1, !dbg !35, !tbaa !13
104 %arrayidx12 = getelementptr inbounds i8, i8* %E, i64 %indvars.iv, !dbg !36
105 %3 = load i8, i8* %arrayidx12, align 1, !dbg !36, !tbaa !13
106 %mul = mul i8 %3, %2, !dbg !37
107 %arrayidx16 = getelementptr inbounds i8, i8* %C, i64 %indvars.iv, !dbg !38
108 store i8 %mul, i8* %arrayidx16, align 1, !dbg !39, !tbaa !13
109 %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !28
110 %exitcond = icmp eq i32 %lftr.wideiv, %N, !dbg !28
111 br i1 %exitcond, label %for.cond.cleanup, label %for.body, !dbg !28, !llvm.loop !40, !prof !59
117 ; Function Attrs: norecurse nounwind ssp uwtable
118 define 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 {
120 %cmp28 = icmp sgt i32 %N, 0, !dbg !42
121 br i1 %cmp28, label %for.body, label %for.cond.cleanup, !dbg !43
123 for.cond.cleanup: ; preds = %for.body, %entry
126 for.body: ; preds = %entry, %for.body
127 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
128 %arrayidx = getelementptr inbounds i8, i8* %A, i64 %indvars.iv, !dbg !45
129 %0 = load i8, i8* %arrayidx, align 1, !dbg !45, !tbaa !13
130 %arrayidx2 = getelementptr inbounds i8, i8* %B, i64 %indvars.iv, !dbg !46
131 %1 = load i8, i8* %arrayidx2, align 1, !dbg !46, !tbaa !13
132 %add = add i8 %1, %0, !dbg !47
133 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !43
134 %arrayidx7 = getelementptr inbounds i8, i8* %A, i64 %indvars.iv.next, !dbg !48
135 store i8 %add, i8* %arrayidx7, align 1, !dbg !49, !tbaa !13
136 %arrayidx9 = getelementptr inbounds i8, i8* %D, i64 %indvars.iv, !dbg !50
137 %2 = load i8, i8* %arrayidx9, align 1, !dbg !50, !tbaa !13
138 %arrayidx12 = getelementptr inbounds i8, i8* %E, i64 %indvars.iv, !dbg !51
139 %3 = load i8, i8* %arrayidx12, align 1, !dbg !51, !tbaa !13
140 %mul = mul i8 %3, %2, !dbg !52
141 %arrayidx16 = getelementptr inbounds i8, i8* %C, i64 %indvars.iv, !dbg !53
142 store i8 %mul, i8* %arrayidx16, align 1, !dbg !54, !tbaa !13
143 %lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !43
144 %exitcond = icmp eq i32 %lftr.wideiv, %N, !dbg !43
145 br i1 %exitcond, label %for.cond.cleanup, label %for.body, !dbg !43, !llvm.loop !55
148 attributes #0 = { norecurse nounwind ssp uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "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" }
151 !llvm.module.flags = !{!3, !4, !5}
154 !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)
155 !1 = !DIFile(filename: "/tmp/s.c", directory: "/tmp")
157 !3 = !{i32 2, !"Dwarf Version", i32 2}
158 !4 = !{i32 2, !"Debug Info Version", i32 3}
159 !5 = !{i32 1, !"PIC Level", i32 2}
160 !6 = !{!"clang version 3.9.0 (trunk 273572) (llvm/trunk 273585)"}
161 !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)
162 !8 = !DISubroutineType(types: !2)
163 !9 = !DILocation(line: 2, column: 20, scope: !7)
164 !10 = !DILocation(line: 2, column: 3, scope: !7)
165 !11 = !DILocation(line: 6, column: 1, scope: !7)
166 !12 = !DILocation(line: 3, column: 16, scope: !7)
167 !13 = !{!14, !14, i64 0}
168 !14 = !{!"omnipotent char", !15, i64 0}
169 !15 = !{!"Simple C/C++ TBAA"}
170 !16 = !DILocation(line: 3, column: 23, scope: !7)
171 !17 = !DILocation(line: 3, column: 21, scope: !7)
172 !18 = !DILocation(line: 3, column: 5, scope: !7)
173 !19 = !DILocation(line: 3, column: 14, scope: !7)
174 !20 = !DILocation(line: 4, column: 12, scope: !7)
175 !21 = !DILocation(line: 4, column: 19, scope: !7)
176 !22 = !DILocation(line: 4, column: 17, scope: !7)
177 !23 = !DILocation(line: 4, column: 5, scope: !7)
178 !24 = !DILocation(line: 4, column: 10, scope: !7)
179 !25 = distinct !{!25, !10}
180 !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)
181 !27 = !DILocation(line: 9, column: 20, scope: !26)
182 !28 = !DILocation(line: 9, column: 3, scope: !26)
183 !29 = !DILocation(line: 13, column: 1, scope: !26)
184 !30 = !DILocation(line: 10, column: 16, scope: !26)
185 !31 = !DILocation(line: 10, column: 23, scope: !26)
186 !32 = !DILocation(line: 10, column: 21, scope: !26)
187 !33 = !DILocation(line: 10, column: 5, scope: !26)
188 !34 = !DILocation(line: 10, column: 14, scope: !26)
189 !35 = !DILocation(line: 11, column: 12, scope: !26)
190 !36 = !DILocation(line: 11, column: 19, scope: !26)
191 !37 = !DILocation(line: 11, column: 17, scope: !26)
192 !38 = !DILocation(line: 11, column: 5, scope: !26)
193 !39 = !DILocation(line: 11, column: 10, scope: !26)
194 !40 = distinct !{!40, !28}
195 !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)
196 !42 = !DILocation(line: 16, column: 20, scope: !41)
197 !43 = !DILocation(line: 16, column: 3, scope: !41)
198 !44 = !DILocation(line: 20, column: 1, scope: !41)
199 !45 = !DILocation(line: 17, column: 16, scope: !41)
200 !46 = !DILocation(line: 17, column: 23, scope: !41)
201 !47 = !DILocation(line: 17, column: 21, scope: !41)
202 !48 = !DILocation(line: 17, column: 5, scope: !41)
203 !49 = !DILocation(line: 17, column: 14, scope: !41)
204 !50 = !DILocation(line: 18, column: 12, scope: !41)
205 !51 = !DILocation(line: 18, column: 19, scope: !41)
206 !52 = !DILocation(line: 18, column: 17, scope: !41)
207 !53 = !DILocation(line: 18, column: 5, scope: !41)
208 !54 = !DILocation(line: 18, column: 10, scope: !41)
209 !55 = distinct !{!55, !43}
210 !56 = !{!"function_entry_count", i64 3}
211 !57 = !{!"function_entry_count", i64 50}
212 !58 = !{!"branch_weights", i32 99, i32 1}
213 !59 = !{!"branch_weights", i32 1, i32 99}