[Mlir-commits] [mlir] [MLIR][Math] Fix math.ceil expansion to avoid undefined behavior on Inf/NaN (PR #170028)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Feb 7 18:03:23 PST 2026
================
@@ -232,6 +232,37 @@ static LogicalResult convertCeilOp(math::CeilOp op, PatternRewriter &rewriter) {
ImplicitLocOpBuilder b(op->getLoc(), rewriter);
Value operand = op.getOperand();
Type opType = operand.getType();
+
+ auto operandETy = getElementTypeOrSelf(opType);
+ unsigned bitWidth = operandETy.getIntOrFloatBitWidth();
+ unsigned mantissaWidth =
+ llvm::cast<FloatType>(operandETy).getFPMantissaWidth() - 1;
+ unsigned exponentWidth = bitWidth - mantissaWidth - 1;
+
+ Type iTy = rewriter.getIntegerType(bitWidth);
+ if (auto shapedTy = dyn_cast<ShapedType>(opType))
+ iTy = shapedTy.clone(iTy);
+
+ Value cMantissaWidth = createIntConst(op->getLoc(), iTy, mantissaWidth, b);
+ Value cBias =
+ createIntConst(op->getLoc(), iTy, (1ull << (exponentWidth - 1)) - 1, b);
----------------
hankluo6 wrote:
Done. Also added a test for FNUZ-suffixed fp8 types.
https://github.com/llvm/llvm-project/pull/170028
More information about the Mlir-commits
mailing list