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