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

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 7 12:20:56 PDT 2016


davide created this revision.
davide added reviewers: majnemer, deadalnix.
davide added a subscriber: llvm-commits.

https://reviews.llvm.org/D15890 introduces a transformation to unpack arrays. This unfortunately causes some fundamental compile time regression, so, let's set a limit on the max size of array we consider for unpacking. Fixes https://llvm.org/bugs/show_bug.cgi?id=30608


https://reviews.llvm.org/D25376

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


Index: llvm/test/Transforms/InstCombine/unpack-fca.ll
===================================================================
--- llvm/test/Transforms/InstCombine/unpack-fca.ll
+++ llvm/test/Transforms/InstCombine/unpack-fca.ll
@@ -158,6 +158,14 @@
   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 }
 
Index: llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -582,6 +582,13 @@
         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();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25376.73965.patch
Type: text/x-patch
Size: 1402 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161007/96a31f2f/attachment.bin>


More information about the llvm-commits mailing list