[InstCombine] Don't unpack arrays that are too large

Differential Revision:  https://reviews.llvm.org/D25376

llvm-svn: 283599
This commit is contained in:
Davide Italiano 2016-10-07 20:57:42 +00:00
parent 998371f3be
commit da11412243
2 changed files with 15 additions and 0 deletions

View File

@ -583,6 +583,13 @@ static Instruction *unpackLoadToAggregate(InstCombiner &IC, LoadInst &LI) {
UndefValue::get(T), NewLoad, 0, Name));
}
// Bail out if the array is too large. Ideally we would like to optimize
// arrays of arbitrary size but this has a terrible impact on compile time.
// The threshold here is chosen arbitrarily, maybe needs a little bit of
// tuning.
if (NumElements > 1024)
return nullptr;
const DataLayout &DL = IC.getDataLayout();
auto EltSize = DL.getTypeAllocSize(ET);
auto Align = LI.getAlignment();

View File

@ -179,6 +179,14 @@ define [2 x %B] @loadArrayOfB([2 x %B]* %ab.ptr) {
ret [2 x %B] %1
}
define [2000 x %B] @loadLargeArrayOfB([2000 x %B]* %ab.ptr) {
; CHECK-LABEL: loadLargeArrayOfB
; CHECK-NEXT: load [2000 x %B], [2000 x %B]* %ab.ptr, align 8
; CHECK-NEXT: ret [2000 x %B]
%1 = load [2000 x %B], [2000 x %B]* %ab.ptr, align 8
ret [2000 x %B] %1
}
%struct.S = type <{ i8, %struct.T }>
%struct.T = type { i32, i32 }