diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td +++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td @@ -1589,6 +1589,7 @@ def DivFOp : FloatArithmeticOp<"divf"> { let summary = "floating point division operation"; + let hasFolder = 1; } //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp --- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp +++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp @@ -1483,6 +1483,15 @@ DimOfCastOp>(context); } +// --------------------------------------------------------------------------- +// DivFOp +// --------------------------------------------------------------------------- + +OpFoldResult DivFOp::fold(ArrayRef operands) { + return constFoldBinaryOp( + operands, [](APFloat a, APFloat b) { return a / b; }); +} + // --------------------------------------------------------------------------- // DmaStartOp // ---------------------------------------------------------------------------