diff options
author | Tom Stellard <thomas.stellard@amd.com> | 2016-11-28 21:35:40 +0000 |
---|---|---|
committer | Tom Stellard <thomas.stellard@amd.com> | 2016-11-28 21:35:40 +0000 |
commit | 227bd4cbe8facfa80f2a176f26cbd802f7447811 (patch) | |
tree | 9c9ee1b84404fa947b16f4e8138207b9119eec53 | |
parent | afb3aea975ad2eea9102d38633a3933fcc3f6f43 (diff) | |
download | llvm-227bd4cbe8facfa80f2a176f26cbd802f7447811.zip llvm-227bd4cbe8facfa80f2a176f26cbd802f7447811.tar.gz llvm-227bd4cbe8facfa80f2a176f26cbd802f7447811.tar.bz2 |
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
------------------------------------------------------------------------
llvm-svn: 288069
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp | 7 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/unpack-fca.ll | 8 |
2 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp index d312983..ed97180 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -579,6 +579,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(); diff --git a/llvm/test/Transforms/InstCombine/unpack-fca.ll b/llvm/test/Transforms/InstCombine/unpack-fca.ll index 47e747c..467c7b7 100644 --- a/llvm/test/Transforms/InstCombine/unpack-fca.ll +++ b/llvm/test/Transforms/InstCombine/unpack-fca.ll @@ -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 } |