Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 4d336bd

Browse files
committed
[LoopDist] Also emit optimization remark on success (-Rpass=)
The option -Rpass=loop-distribute now reports the loops that were distributed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268006 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent dcfb1a6 commit 4d336bd

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

lib/Transforms/Scalar/LoopDistribute.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,9 @@ class LoopDistributeForLoop {
742742
}
743743

744744
++NumLoopsDistributed;
745+
// Report the success.
746+
emitOptimizationRemark(F->getContext(), LDIST_NAME, *F, L->getStartLoc(),
747+
"distributed loop");
745748
return true;
746749
}
747750

test/Transforms/LoopDistribute/diagnostics.ll

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
; 10 A[i] = B[i] * C[i];
2020
; 11 }
2121
; 12 }
22+
; 13
23+
; 14 void success (char *A, char *B, char *C, char *D, char *E, int N) {
24+
; 15 for(int i = 0; i < N; i++) {
25+
; 16 A[i + 1] = A[i] + B[i];
26+
; 17 C[i] = D[i] * E[i];
27+
; 18 }
28+
; 19 }
2229

2330
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
2431
target triple = "x86_64-apple-macosx10.11.0"
@@ -84,6 +91,41 @@ for.cond.cleanup:
8491
ret void, !dbg !25
8592
}
8693

94+
; REMARKS: remark: /tmp/t.c:15:3: distributed loop
95+
96+
define void @success(i8* %A, i8* %B, i8* %C, i8* %D, i8* %E, i32 %N) !dbg !31 {
97+
entry:
98+
%cmp28 = icmp sgt i32 %N, 0, !dbg !32
99+
br i1 %cmp28, label %ph, label %for.cond.cleanup, !dbg !33
100+
101+
ph:
102+
br label %for.body
103+
104+
for.body:
105+
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %ph ]
106+
%arrayidx = getelementptr inbounds i8, i8* %A, i64 %indvars.iv, !dbg !35
107+
%0 = load i8, i8* %arrayidx, align 1, !dbg !35, !tbaa !13
108+
%arrayidx2 = getelementptr inbounds i8, i8* %B, i64 %indvars.iv, !dbg !36
109+
%1 = load i8, i8* %arrayidx2, align 1, !dbg !36, !tbaa !13
110+
%add = add i8 %1, %0, !dbg !37
111+
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !33
112+
%arrayidx7 = getelementptr inbounds i8, i8* %A, i64 %indvars.iv.next, !dbg !38
113+
store i8 %add, i8* %arrayidx7, align 1, !dbg !39, !tbaa !13
114+
%arrayidx9 = getelementptr inbounds i8, i8* %D, i64 %indvars.iv, !dbg !40
115+
%2 = load i8, i8* %arrayidx9, align 1, !dbg !40, !tbaa !13
116+
%arrayidx12 = getelementptr inbounds i8, i8* %E, i64 %indvars.iv, !dbg !41
117+
%3 = load i8, i8* %arrayidx12, align 1, !dbg !41, !tbaa !13
118+
%mul = mul i8 %3, %2, !dbg !42
119+
%arrayidx16 = getelementptr inbounds i8, i8* %C, i64 %indvars.iv, !dbg !43
120+
store i8 %mul, i8* %arrayidx16, align 1, !dbg !44, !tbaa !13
121+
%lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !33
122+
%exitcond = icmp eq i32 %lftr.wideiv, %N, !dbg !33
123+
br i1 %exitcond, label %for.cond.cleanup, label %for.body, !dbg !33
124+
125+
for.cond.cleanup:
126+
ret void, !dbg !34
127+
}
128+
87129
!llvm.dbg.cu = !{!0}
88130
!llvm.module.flags = !{!3, !4}
89131

@@ -116,3 +158,17 @@ for.cond.cleanup:
116158
!28 = !DILocation(line: 10, column: 17, scope: !22)
117159
!29 = !DILocation(line: 10, column: 5, scope: !22)
118160
!30 = !DILocation(line: 10, column: 10, scope: !22)
161+
!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)
162+
!32 = !DILocation(line: 15, column: 20, scope: !31)
163+
!33 = !DILocation(line: 15, column: 3, scope: !31)
164+
!34 = !DILocation(line: 19, column: 1, scope: !31)
165+
!35 = !DILocation(line: 16, column: 16, scope: !31)
166+
!36 = !DILocation(line: 16, column: 23, scope: !31)
167+
!37 = !DILocation(line: 16, column: 21, scope: !31)
168+
!38 = !DILocation(line: 16, column: 5, scope: !31)
169+
!39 = !DILocation(line: 16, column: 14, scope: !31)
170+
!40 = !DILocation(line: 17, column: 12, scope: !31)
171+
!41 = !DILocation(line: 17, column: 19, scope: !31)
172+
!42 = !DILocation(line: 17, column: 17, scope: !31)
173+
!43 = !DILocation(line: 17, column: 5, scope: !31)
174+
!44 = !DILocation(line: 17, column: 10, scope: !31)

0 commit comments

Comments
 (0)