@@ -5212,8 +5212,10 @@ AllocaInst *SROA::rewritePartition(AllocaInst &AI, AllocaSlices &AS,
52125212 const DataLayout &DL = AI.getDataLayout ();
52135213 auto ComputePartitionTy = [&]() -> std::tuple<Type *, bool , VectorType *> {
52145214 // First check if the partition is viable for vetor promotion. If it is
5215- // via a floating-point vector, we are done because we would never prefer integer widening.
5216- VectorType *VecTy = isVectorPromotionViable (P, DL, AI.getFunction ()->getVScaleValue ());
5215+ // via a floating-point vector, we are done because we would never prefer
5216+ // integer widening.
5217+ VectorType *VecTy =
5218+ isVectorPromotionViable (P, DL, AI.getFunction ()->getVScaleValue ());
52175219 if (VecTy) {
52185220 if (VecTy->getElementType ()->isFloatingPointTy ()) {
52195221 return {VecTy, false , VecTy};
@@ -5231,26 +5233,34 @@ AllocaInst *SROA::rewritePartition(AllocaInst &AI, AllocaSlices &AS,
52315233
52325234 if (VecTy)
52335235 return {VecTy, false , VecTy};
5234- return {CommonUseTy.first , isIntegerWideningViable (P, CommonUseTy.first , DL), nullptr };
5236+ return {CommonUseTy.first ,
5237+ isIntegerWideningViable (P, CommonUseTy.first , DL), nullptr };
52355238 }
52365239 }
52375240
5238- // If not, can we find an appropriate subtype in the original allocated type?
5239- if (Type *TypePartitionTy = getTypePartition (DL, AI.getAllocatedType (), P.beginOffset (), P.size ())) {
5240- if (TypePartitionTy->isArrayTy () && TypePartitionTy->getArrayElementType ()->isIntegerTy () && DL.isLegalInteger (P.size () * 8 ))
5241+ // If not, can we find an appropriate subtype in the original allocated
5242+ // type?
5243+ if (Type *TypePartitionTy = getTypePartition (DL, AI.getAllocatedType (),
5244+ P.beginOffset (), P.size ())) {
5245+ if (TypePartitionTy->isArrayTy () &&
5246+ TypePartitionTy->getArrayElementType ()->isIntegerTy () &&
5247+ DL.isLegalInteger (P.size () * 8 ))
52415248 TypePartitionTy = Type::getIntNTy (*C, P.size () * 8 );
5242-
5249+
52435250 if (isIntegerWideningViable (P, TypePartitionTy, DL))
52445251 return {TypePartitionTy, true , nullptr };
52455252 if (VecTy)
52465253 return {VecTy, false , VecTy};
5247- if (CommonUseTy.second && DL.getTypeAllocSize (CommonUseTy.second ).getFixedValue () >= P.size () && isIntegerWideningViable (P, CommonUseTy.second , DL))
5254+ if (CommonUseTy.second &&
5255+ DL.getTypeAllocSize (CommonUseTy.second ).getFixedValue () >= P.size () &&
5256+ isIntegerWideningViable (P, CommonUseTy.second , DL))
52485257 return {CommonUseTy.second , true , nullptr };
52495258 return {TypePartitionTy, false , nullptr };
52505259 }
52515260
52525261 // If still not, can we use the largest bitwidth integer type used?
5253- if (CommonUseTy.second && DL.getTypeAllocSize (CommonUseTy.second ).getFixedValue () >= P.size ())
5262+ if (CommonUseTy.second &&
5263+ DL.getTypeAllocSize (CommonUseTy.second ).getFixedValue () >= P.size ())
52545264 return {CommonUseTy.second , false , nullptr };
52555265
52565266 if (DL.isLegalInteger (P.size () * 8 ))
0 commit comments