[SVE] Fix getAlignmentInfo for scalable vectors

When calculating the natural alignment for scalable vectors it
is acceptable to calculate an allocation size based on the minimum
number of elements in the vector.

This code path is exercised by an existing test:

  CodeGen/AArch64/sve-intrinsics-int-arith.ll

Differential Revision: https://reviews.llvm.org/D79475
This commit is contained in:
David Sherwood 2020-05-05 16:47:31 +01:00
parent 350645594e
commit a400aa5faf
1 changed files with 4 additions and 1 deletions

View File

@ -559,7 +559,10 @@ Align DataLayout::getAlignmentInfo(AlignTypeEnum AlignType, uint32_t BitWidth,
// with what clang and llvm-gcc do.
unsigned Alignment =
getTypeAllocSize(cast<VectorType>(Ty)->getElementType());
Alignment *= cast<VectorType>(Ty)->getNumElements();
// We're only calculating a natural alignment, so it doesn't have to be
// based on the full size for scalable vectors. Using the minimum element
// count should be enough here.
Alignment *= cast<VectorType>(Ty)->getElementCount().Min;
Alignment = PowerOf2Ceil(Alignment);
return Align(Alignment);
}