hoist the check for alloca size up so that it controls CanConvertToScalar
authorChris Lattner <sabre@nondot.org>
Sun, 1 Mar 2009 02:26:47 +0000 (02:26 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 1 Mar 2009 02:26:47 +0000 (02:26 +0000)
as well as isSafeAllocaToScalarRepl.

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

lib/Transforms/Scalar/ScalarReplAggregates.cpp

index 3a4201bf81e894ca87f04702e576df7c881e446a..92ac76be74f34dfcf7724ed8ae1c27e4fcf3e823 100644 (file)
@@ -253,11 +253,13 @@ bool SROA::performScalarRepl(Function &F) {
     // (allocations OF arrays are ok though), and an allocation of a scalar
     // value cannot be decomposed at all.
     uint64_t AllocaSize = TD->getTypePaddedSize(AI->getAllocatedType());
-        
+
+    // Do not promote any struct whose size is too big.
+    if (AllocaSize < SRThreshold)
+      continue;
+    
     if ((isa<StructType>(AI->getAllocatedType()) ||
          isa<ArrayType>(AI->getAllocatedType())) &&
-        // Do not promote any struct whose size is too big.
-        AllocaSize < SRThreshold &&
         // Do not promote any struct into more than "32" separate vars.
         getNumSAElements(AI->getAllocatedType()) < SRThreshold/4) {
       // Check that all of the users of the allocation are capable of being