[Mlir-commits] [mlir] [mlir] Fix MemRefType alignment in ConvertVectorToLLVM (PR #137389)
Lily Orth-Smith
llvmlistbot at llvm.org
Fri Apr 25 13:55:52 PDT 2025
https://github.com/electriclilies updated https://github.com/llvm/llvm-project/pull/137389
>From 18dfae0f4cddc8a255319f2c27546e66cd3ace42 Mon Sep 17 00:00:00 2001
From: Lily Orth-Smith <lorthsmith at microsoft.com>
Date: Fri, 25 Apr 2025 19:51:30 +0000
Subject: [PATCH] Fix how we get alignment for memrefs
---
.../Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
index 076e5512f375b..79be34b204649 100644
--- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
+++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
@@ -70,15 +70,19 @@ static Value extractOne(ConversionPatternRewriter &rewriter,
// Helper that returns data layout alignment of a memref.
LogicalResult getMemRefAlignment(const LLVMTypeConverter &typeConverter,
MemRefType memrefType, unsigned &align) {
- Type elementTy = typeConverter.convertType(memrefType.getElementType());
- if (!elementTy)
+ // Align MemRefTypes to the alignment of a VectorType with the same
+ // size and dtype.
+ Type convertedVecType = typeConverter.convertType(
+ VectorType::get(memrefType.getShape(), memrefType.getElementType()));
+ if (!convertedVecType)
return failure();
// TODO: this should use the MLIR data layout when it becomes available and
// stop depending on translation.
llvm::LLVMContext llvmContext;
align = LLVM::TypeToLLVMIRTranslator(llvmContext)
- .getPreferredAlignment(elementTy, typeConverter.getDataLayout());
+ .getPreferredAlignment(convertedVecType,
+ typeConverter.getDataLayout());
return success();
}
More information about the Mlir-commits
mailing list