Skip to content

Commit a400aa5

Browse files
committed
[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
1 parent 3506455 commit a400aa5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

llvm/lib/IR/DataLayout.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,10 @@ Align DataLayout::getAlignmentInfo(AlignTypeEnum AlignType, uint32_t BitWidth,
559559
// with what clang and llvm-gcc do.
560560
unsigned Alignment =
561561
getTypeAllocSize(cast<VectorType>(Ty)->getElementType());
562-
Alignment *= cast<VectorType>(Ty)->getNumElements();
562+
// We're only calculating a natural alignment, so it doesn't have to be
563+
// based on the full size for scalable vectors. Using the minimum element
564+
// count should be enough here.
565+
Alignment *= cast<VectorType>(Ty)->getElementCount().Min;
563566
Alignment = PowerOf2Ceil(Alignment);
564567
return Align(Alignment);
565568
}

0 commit comments

Comments
 (0)