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>