]> granicus.if.org Git - llvm/commitdiff
[InstCombine] Don't unpack arrays that are too large
authorDavide Italiano <davide@freebsd.org>
Fri, 7 Oct 2016 20:57:42 +0000 (20:57 +0000)
committerDavide Italiano <davide@freebsd.org>
Fri, 7 Oct 2016 20:57:42 +0000 (20:57 +0000)
Differential Revision:  https://reviews.llvm.org/D25376

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283599 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
test/Transforms/InstCombine/unpack-fca.ll

index 8295899251a1f7d504bf36be754d57c019d9bce4..02865d46cb17eb76c32a1bfae5a5841cfe7e3a98 100644 (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();
index 47e747ccc468aa3bfe9a1eb00a6cc1b9345ee729..467c7b74e5e9f501fa735a56b14b489c8bda0892 100644 (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 }