diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td index 8e3f1f1a7a85..8db6129dbb88 100644 --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td +++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td @@ -1589,6 +1589,7 @@ def DimOp : Std_Op<"dim", [NoSideEffect]> { 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 index e1be47f54798..1718ab14d5d1 100644 --- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp +++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp @@ -1483,6 +1483,15 @@ void DimOp::getCanonicalizationPatterns(OwningRewritePatternList &results, DimOfCastOp>(context); } +// --------------------------------------------------------------------------- +// DivFOp +// --------------------------------------------------------------------------- + +OpFoldResult DivFOp::fold(ArrayRef operands) { + return constFoldBinaryOp( + operands, [](APFloat a, APFloat b) { return a / b; }); +} + // --------------------------------------------------------------------------- // DmaStartOp // ---------------------------------------------------------------------------