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

Commit 7e79c45

Browse files
committed
Merging r283599:
------------------------------------------------------------------------ r283599 | davide | 2016-10-07 13:57:42 -0700 (Fri, 07 Oct 2016) | 4 lines [InstCombine] Don't unpack arrays that are too large Differential Revision: https://reviews.llvm.org/D25376 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_39@288069 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 0cdf5ee commit 7e79c45

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,13 @@ static Instruction *unpackLoadToAggregate(InstCombiner &IC, LoadInst &LI) {
579579
UndefValue::get(T), NewLoad, 0, Name));
580580
}
581581

582+
// Bail out if the array is too large. Ideally we would like to optimize
583+
// arrays of arbitrary size but this has a terrible impact on compile time.
584+
// The threshold here is chosen arbitrarily, maybe needs a little bit of
585+
// tuning.
586+
if (NumElements > 1024)
587+
return nullptr;
588+
582589
const DataLayout &DL = IC.getDataLayout();
583590
auto EltSize = DL.getTypeAllocSize(ET);
584591
auto Align = LI.getAlignment();

test/Transforms/InstCombine/unpack-fca.ll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@ define [2 x %B] @loadArrayOfB([2 x %B]* %ab.ptr) {
179179
ret [2 x %B] %1
180180
}
181181

182+
define [2000 x %B] @loadLargeArrayOfB([2000 x %B]* %ab.ptr) {
183+
; CHECK-LABEL: loadLargeArrayOfB
184+
; CHECK-NEXT: load [2000 x %B], [2000 x %B]* %ab.ptr, align 8
185+
; CHECK-NEXT: ret [2000 x %B]
186+
%1 = load [2000 x %B], [2000 x %B]* %ab.ptr, align 8
187+
ret [2000 x %B] %1
188+
}
189+
182190
%struct.S = type <{ i8, %struct.T }>
183191
%struct.T = type { i32, i32 }
184192

0 commit comments

Comments
 (0)