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

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 7 13:57:42 PDT 2016


Author: davide
Date: Fri Oct  7 15:57:42 2016
New Revision: 283599

URL: http://llvm.org/viewvc/llvm-project?rev=283599&view=rev
Log:
[InstCombine] Don't unpack arrays that are too large

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

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
    llvm/trunk/test/Transforms/InstCombine/unpack-fca.ll

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp?rev=283599&r1=283598&r2=283599&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp Fri Oct  7 15:57:42 2016
@@ -583,6 +583,13 @@ static Instruction *unpackLoadToAggregat
         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();

Modified: llvm/trunk/test/Transforms/InstCombine/unpack-fca.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/unpack-fca.ll?rev=283599&r1=283598&r2=283599&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/unpack-fca.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/unpack-fca.ll Fri Oct  7 15:57:42 2016
@@ -179,6 +179,14 @@ define [2 x %B] @loadArrayOfB([2 x %B]*
   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 }
 




More information about the llvm-commits mailing list