@@ -5261,7 +5261,7 @@ selectPartitionType(Partition &P, const DataLayout &DL, AllocaInst &AI,
52615261
52625262 // Check if there is a common type that all slices of the partition use that
52635263 // spans the partition.
5264- auto [CommonUseTy, LargestIntTy] =
5264+ auto [CommonUseTy, LargestIntTy, OnlyIntrinsicUsers ] =
52655265 findCommonType (P.begin (), P.end (), P.endOffset ());
52665266 if (CommonUseTy) {
52675267 TypeSize CommonUseSize = DL.getTypeAllocSize (CommonUseTy);
@@ -5299,6 +5299,15 @@ selectPartitionType(Partition &P, const DataLayout &DL, AllocaInst &AI,
52995299 isIntegerWideningViable (P, LargestIntTy, DL))
53005300 return {LargestIntTy, true , nullptr };
53015301
5302+ // If there are only intrinsic users of an aggregate type, try to
5303+ // represent as a legal integer type because we are probably just copying
5304+ // data around and the integer can be promoted.
5305+ if (OnlyIntrinsicUsers && DL.isLegalInteger (P.size () * 8 ) &&
5306+ TypePartitionTy->isAggregateType ())
5307+ auto *IntNTy = Type::getIntNTy (*C, P.size () * 8 );
5308+ return {IntNTy, isIntegerWideningViable (P, IntNTy, DL), nullptr };
5309+ }
5310+
53025311 // Fallback to TypePartitionTy and we probably won't promote.
53035312 return {TypePartitionTy, false , nullptr };
53045313 }
0 commit comments