[Mlir-commits] [flang] [mlir] [mlir] Align num elements type to LLVM ArrayType (PR #93230)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Wed May 29 09:44:49 PDT 2024
================
@@ -632,8 +632,25 @@ llvm::Constant *mlir::LLVM::detail::getLLVMConstant(
llvm::ElementCount::get(numElements, /*Scalable=*/isScalable), child);
if (llvmType->isArrayTy()) {
auto *arrayType = llvm::ArrayType::get(elementType, numElements);
- SmallVector<llvm::Constant *, 8> constants(numElements, child);
- return llvm::ConstantArray::get(arrayType, constants);
+ if (child->isZeroValue()) {
+ return llvm::ConstantAggregateZero::get(arrayType);
+ } else {
+ if (llvm::ConstantDataSequential::isElementTypeCompatible(elementType)) {
+ // TODO: Handle all compatible types. This code only handle i32.
----------------
ftynse wrote:
I suspect we want to have it for efficiency reasons. We have had compile time issues with large nested constants previously that I suspect using ConstantData avoids. This is perfectly fine for a separate PR.
https://github.com/llvm/llvm-project/pull/93230
More information about the Mlir-commits
mailing list