[Mlir-commits] [mlir] [mlir][arith] Add rounding mode flags to binary arithmetic operations (PR #188458)
Renato Golin
llvmlistbot at llvm.org
Wed Mar 25 03:54:35 PDT 2026
================
@@ -1121,9 +1126,14 @@ OpFoldResult arith::SubFOp::fold(FoldAdaptor adaptor) {
if (matchPattern(adaptor.getRhs(), m_PosZeroFloat()))
return getLhs();
+ auto rm = getRoundingmodeAttr();
return constFoldBinaryOp<FloatAttr>(
- adaptor.getOperands(),
- [](const APFloat &a, const APFloat &b) { return a - b; });
+ adaptor.getOperands(), [rm](const APFloat &a, const APFloat &b) {
+ APFloat result(a);
+ result.subtract(b, rm ? convertArithRoundingModeToLLVMIR(rm.getValue())
----------------
rengolin wrote:
could we change `convertArithRoundingModeToLLVMIR` to return the default value when rm is null? Or is that bypassing too many layers of abstraction?
https://github.com/llvm/llvm-project/pull/188458
More information about the Mlir-commits
mailing list