Skip to content

Commit 4a07bbe

Browse files
committedAug 22, 2017
[IRBuilder] Only emit alias scop metadata for arrays, but not scalars
Summary: There is no need to emit alias metadata for scalars, as basicaa will easily distinguish them from arrays. This reduces the size of the metadata we generate. This is especially useful after we moved to -polly-position=before-vectorizer, where a lot more scalar dependences are introduced, which increased the size of the alias analysis metadata and made us commonly reach the limits after which we do not emit alias metadata that have been introduced to prevent quadratic growth of this alias metadata. This improves 2mm performance from 1.5 seconds to 0.17 seconds. Reviewers: Meinersbur, bollu, singam-sanjay Reviewed By: Meinersbur Subscribers: pollydev, llvm-commits Tags: #polly Differential Revision: https://reviews.llvm.org/D37028 llvm-svn: 311498
1 parent e158f7c commit 4a07bbe

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed
 

‎polly/lib/CodeGen/IRBuilder.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "polly/CodeGen/IRBuilder.h"
1616
#include "polly/ScopInfo.h"
1717
#include "polly/Support/ScopHelper.h"
18+
#include "llvm/ADT/SmallVector.h"
1819
#include "llvm/IR/Metadata.h"
1920
#include "llvm/Support/Debug.h"
2021

@@ -60,21 +61,28 @@ void ScopAnnotator::buildAliasScopes(Scop &S) {
6061
AliasScopeMap.clear();
6162
OtherAliasScopeListMap.clear();
6263

64+
// We are only interested in arrays, but no scalar references. Scalars should
65+
// be handled easily by basicaa.
66+
SmallVector<ScopArrayInfo *, 10> Arrays;
67+
for (ScopArrayInfo *Array : S.arrays())
68+
if (Array->isArrayKind())
69+
Arrays.push_back(Array);
70+
6371
// The construction of alias scopes is quadratic in the number of arrays
6472
// involved. In case of too many arrays, skip the construction of alias
6573
// information to avoid quadratic increases in compile time and code size.
66-
if (std::distance(S.array_begin(), S.array_end()) > MaxArraysInAliasScops)
74+
if (Arrays.size() > MaxArraysInAliasScops)
6775
return;
6876

6977
std::string AliasScopeStr = "polly.alias.scope.";
70-
for (const ScopArrayInfo *Array : S.arrays()) {
78+
for (const ScopArrayInfo *Array : Arrays) {
7179
assert(Array->getBasePtr() && "Base pointer must be present");
7280
AliasScopeMap[Array->getBasePtr()] =
7381
getID(Ctx, AliasScopeDomain,
7482
MDString::get(Ctx, (AliasScopeStr + Array->getName()).c_str()));
7583
}
7684

77-
for (const ScopArrayInfo *Array : S.arrays()) {
85+
for (const ScopArrayInfo *Array : Arrays) {
7886
MDNode *AliasScopeList = MDNode::get(Ctx, {});
7987
for (const auto &AliasScopePair : AliasScopeMap) {
8088
if (Array->getBasePtr() == AliasScopePair.first)

‎polly/test/Isl/CodeGen/MemAccess/create_arrays.ll

+8-9
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,14 @@
3232
; CODEGEN: {{%.*}} = load double, double* %polly.access.E, align 8, !alias.scope [[TAG0:![0-9]+]], !noalias [[TAG2:![0-9]+]]
3333
; CODEGEN: store double {{%.*}}, double* %scevgep36, align 8, !alias.scope [[TAG5:![0-9]+]], !noalias [[TAG8:![0-9]+]]
3434
;
35-
; CODEGEN-DAG: [[TAG0]] = distinct !{[[TAG0]], [[TAG1:![0-9]+]], !"polly.alias.scope.E"}
36-
; CODEGEN-DAG: [[TAG1]] = distinct !{[[TAG1]], !"polly.alias.scope.domain"}
37-
; CODEGEN-DAG: [[TAG2]] = !{[[TAG3:![0-9]+]], [[TAG4:![0-9]+]], [[TAG5:![0-9]+]], [[TAG6:![0-9]+]], [[TAG7:![0-9]+]]}
38-
; CODEGEN-DAG: [[TAG3]] = distinct !{[[TAG3]], [[TAG1]], !"polly.alias.scope.MemRef_B"}
39-
; CODEGEN-DAG: [[TAG4]] = distinct !{[[TAG4]], [[TAG1]], !"polly.alias.scope.MemRef_beta"}
40-
; CODEGEN-DAG: [[TAG5]] = distinct !{[[TAG5]], [[TAG1]], !"polly.alias.scope.MemRef_A"}
41-
; CODEGEN-DAG: [[TAG6]] = distinct !{[[TAG6]], [[TAG1]], !"polly.alias.scope.D"}
42-
; CODEGEN-DAG: [[TAG7]] = distinct !{[[TAG7]], [[TAG1]], !"polly.alias.scope.F"}
43-
; CODEGEN-DAG: [[TAG8]] = !{[[TAG3]], [[TAG4]], [[TAG6]], [[TAG0]], [[TAG7]]}
35+
; CODEGEN: [[TAG0]] = distinct !{[[TAG0]], [[TAG1:![0-9]+]], !"polly.alias.scope.E"}
36+
; CODEGEN: [[TAG1]] = distinct !{[[TAG1]], !"polly.alias.scope.domain"}
37+
; CODEGEN: [[TAG2]] = !{[[TAG3:![0-9]+]], [[TAG4:![0-9]+]], [[TAG5:![0-9]+]], [[TAG6:![0-9]+]]}
38+
; CODEGEN: [[TAG3]] = distinct !{[[TAG3]], [[TAG1]], !"polly.alias.scope.MemRef_B"}
39+
; CODEGEN: [[TAG4]] = distinct !{[[TAG4]], [[TAG1]], !"polly.alias.scope.MemRef_A"}
40+
; CODEGEN: [[TAG5]] = distinct !{[[TAG5]], [[TAG1]], !"polly.alias.scope.D"}
41+
; CODEGEN: [[TAG6]] = distinct !{[[TAG6]], [[TAG1]], !"polly.alias.scope.F"}
42+
; CODEGEN: [[TAG7:![0-9]+]] = !{[[TAG3]], [[TAG5]], [[TAG0]], [[TAG6]]}
4443
;
4544
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4645
target triple = "x86_64-unknown-unknown"

‎polly/test/ScheduleOptimizer/pattern-matching-based-opts_10.ll

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
; This test case checks whether Polly generates second level alias metadata
1313
; to distinguish the specific accesses in case of the ublas gemm kernel.
1414
;
15-
; CHECK: !13 = distinct !{!13, !0, !"second level alias metadata"}
15+
; CHECK: !11 = distinct !{!11, !0, !"second level alias metadata"}
16+
; CHECK: !12 = distinct !{!12, !0, !"second level alias metadata"}
17+
; CHECK: !13 = !{!3, !4, !5, !6, !11}
1618
; CHECK: !14 = distinct !{!14, !0, !"second level alias metadata"}
17-
; CHECK: !15 = !{!3, !4, !5, !6, !7, !8, !13}
19+
; CHECK: !15 = !{!3, !4, !5, !6, !11, !12}
1820
; CHECK: !16 = distinct !{!16, !0, !"second level alias metadata"}
19-
; CHECK: !17 = !{!3, !4, !5, !6, !7, !8, !13, !14}
20-
; CHECK: !18 = distinct !{!18, !0, !"second level alias metadata"}
21-
; CHECK: !19 = !{!3, !4, !5, !6, !7, !8, !13, !14, !16}
21+
; CHECK: !17 = !{!3, !4, !5, !6, !11, !12, !14}
2222
;
2323
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
2424
target triple = "x86_64-unknown-unknown"

0 commit comments

Comments
 (0)
Please sign in to comment.