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