[flang-commits] [flang] [mlir] [mlir] Align num elements type to LLVM ArrayType (PR #93230)

Tobias Gysi via flang-commits flang-commits at lists.llvm.org
Wed May 29 11:14:31 PDT 2024


================
@@ -632,8 +632,40 @@ 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 {
----------------
gysit wrote:

nit: can you drop the else since there is a return in the if body? That should save one indention for the else body.


https://github.com/llvm/llvm-project/pull/93230


More information about the flang-commits mailing list