From dbca9169faf13f02d09fef9586700a785e8a7da6 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Thu, 25 Sep 2025 07:28:59 -0700 Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?= =?UTF-8?q?l=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.7 --- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | 2 +- mlir/test/Target/LLVMIR/global_float_array.mlir | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 mlir/test/Target/LLVMIR/global_float_array.mlir diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp index adc5a74e2031f..5a3eb209f0a92 100644 --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -647,7 +647,7 @@ llvm::Constant *mlir::LLVM::detail::getLLVMConstant( llvm::ElementCount::get(numElements, /*Scalable=*/isScalable), child); if (llvmType->isArrayTy()) { auto *arrayType = llvm::ArrayType::get(elementType, numElements); - if (child->isZeroValue()) { + if (child->isZeroValue() && !elementType->isFPOrFPVectorTy()) { return llvm::ConstantAggregateZero::get(arrayType); } else { if (llvm::ConstantDataSequential::isElementTypeCompatible( diff --git a/mlir/test/Target/LLVMIR/global_float_array.mlir b/mlir/test/Target/LLVMIR/global_float_array.mlir new file mode 100644 index 0000000000000..eba7948d2c55e --- /dev/null +++ b/mlir/test/Target/LLVMIR/global_float_array.mlir @@ -0,0 +1,4 @@ +// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s + +// CHECK: @test = internal global [1 x float] [float -0.000000e+00] +llvm.mlir.global internal @test(dense<-0.000000e+00> : tensor<1xf32>) {addr_space = 0 : i32} : !llvm.array<1 x f32>