diff options
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp | 7 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/unpack-fca.ll | 9 |
2 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp index 02865d46cb1..49edd540787 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -1095,6 +1095,13 @@ static bool unpackStoreToAggregate(InstCombiner &IC, StoreInst &SI) { return true; } + // 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 false; + const DataLayout &DL = IC.getDataLayout(); auto EltSize = DL.getTypeAllocSize(AT->getElementType()); auto Align = SI.getAlignment(); diff --git a/llvm/test/Transforms/InstCombine/unpack-fca.ll b/llvm/test/Transforms/InstCombine/unpack-fca.ll index 467c7b74e5e..3c5e4177d69 100644 --- a/llvm/test/Transforms/InstCombine/unpack-fca.ll +++ b/llvm/test/Transforms/InstCombine/unpack-fca.ll @@ -49,6 +49,15 @@ define void @storeArrayOfA([1 x %A]* %aa.ptr) { ret void } +define void @storeLargeArrayOfA([2000 x %A]* %aa.ptr) { +; CHECK-LABEL: storeLargeArrayOfA +; CHECK-NEXT: store [2000 x %A] +; CHECK-NEXT: ret void + %i1 = insertvalue [2000 x %A] undef, %A { %A__vtbl* @A__vtblZ }, 1 + store [2000 x %A] %i1, [2000 x %A]* %aa.ptr, align 8 + ret void +} + define void @storeStructOfArrayOfA({ [1 x %A] }* %saa.ptr) { ; CHECK-LABEL: storeStructOfArrayOfA ; CHECK-NEXT: [[GEP:%[a-z0-9\.]+]] = getelementptr inbounds { [1 x %A] }, { [1 x %A] }* %saa.ptr, i64 0, i32 0, i64 0, i32 0 |