Skip to content

Commit b6ae30c

Browse files
committed
[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/trunk@283599 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 7e1f502 commit b6ae30c

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
@@ -583,6 +583,13 @@ static Instruction *unpackLoadToAggregate(InstCombiner &IC, LoadInst &LI) {
583583
UndefValue::get(T), NewLoad, 0, Name));
584584
}
585585

586+
// Bail out if the array is too large. Ideally we would like to optimize
587+
// arrays of arbitrary size but this has a terrible impact on compile time.
588+
// The threshold here is chosen arbitrarily, maybe needs a little bit of
589+
// tuning.
590+
if (NumElements > 1024)
591+
return nullptr;
592+
586593
const DataLayout &DL = IC.getDataLayout();
587594
auto EltSize = DL.getTypeAllocSize(ET);
588595
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)