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

Commit e0af6c9

Browse files
committed
Merging r283612:
------------------------------------------------------------------------ r283612 | davide | 2016-10-07 14:53:09 -0700 (Fri, 07 Oct 2016) | 5 lines [InstCombine] Don't unpack arrays that are too large (part 2). This is similar to r283599, but for store instructions. Thanks to David for pointing out! ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_39@288070 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 7e79c45 commit e0af6c9

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,13 @@ static bool unpackStoreToAggregate(InstCombiner &IC, StoreInst &SI) {
10881088
return true;
10891089
}
10901090

1091+
// Bail out if the array is too large. Ideally we would like to optimize
1092+
// arrays of arbitrary size but this has a terrible impact on compile time.
1093+
// The threshold here is chosen arbitrarily, maybe needs a little bit of
1094+
// tuning.
1095+
if (NumElements > 1024)
1096+
return false;
1097+
10911098
const DataLayout &DL = IC.getDataLayout();
10921099
auto EltSize = DL.getTypeAllocSize(AT->getElementType());
10931100
auto Align = SI.getAlignment();

test/Transforms/InstCombine/unpack-fca.ll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ define void @storeArrayOfA([1 x %A]* %aa.ptr) {
4949
ret void
5050
}
5151

52+
define void @storeLargeArrayOfA([2000 x %A]* %aa.ptr) {
53+
; CHECK-LABEL: storeLargeArrayOfA
54+
; CHECK-NEXT: store [2000 x %A]
55+
; CHECK-NEXT: ret void
56+
%i1 = insertvalue [2000 x %A] undef, %A { %A__vtbl* @A__vtblZ }, 1
57+
store [2000 x %A] %i1, [2000 x %A]* %aa.ptr, align 8
58+
ret void
59+
}
60+
5261
define void @storeStructOfArrayOfA({ [1 x %A] }* %saa.ptr) {
5362
; CHECK-LABEL: storeStructOfArrayOfA
5463
; CHECK-NEXT: [[GEP:%[a-z0-9\.]+]] = getelementptr inbounds { [1 x %A] }, { [1 x %A] }* %saa.ptr, i64 0, i32 0, i64 0, i32 0

0 commit comments

Comments
 (0)