Skip to content

Commit cc0fecf

Browse files
[MLIR][MLIRToLLVM] Fix zero fp value to array translation (#160713)
The translator should not generate zeroinitilizer on fp all zero values, since it may affect signedness of zeroes Fixes #160437
1 parent 1867ca7 commit cc0fecf

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ llvm::Constant *mlir::LLVM::detail::getLLVMConstant(
647647
llvm::ElementCount::get(numElements, /*Scalable=*/isScalable), child);
648648
if (llvmType->isArrayTy()) {
649649
auto *arrayType = llvm::ArrayType::get(elementType, numElements);
650-
if (child->isZeroValue()) {
650+
if (child->isZeroValue() && !elementType->isFPOrFPVectorTy()) {
651651
return llvm::ConstantAggregateZero::get(arrayType);
652652
} else {
653653
if (llvm::ConstantDataSequential::isElementTypeCompatible(
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s
2+
3+
// CHECK: @test = internal global [1 x float] [float -0.000000e+00]
4+
llvm.mlir.global internal @test(dense<-0.000000e+00> : tensor<1xf32>) {addr_space = 0 : i32} : !llvm.array<1 x f32>

0 commit comments

Comments
 (0)