forked from OSchip/llvm-project
Implement constant folding for DivFOp
Add a constant folder for DivFOp. Analogous to existing folders for
AddFOp, SubFOp, and MulFOp. Matches the behavior of existing LLVM
constant folding (999f5da6b3/llvm/lib/IR/ConstantFold.cpp (L1432)
).
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D94939
This commit is contained in:
parent
96ef4f307d
commit
1bf2b1665b
|
@ -1589,6 +1589,7 @@ def DimOp : Std_Op<"dim", [NoSideEffect]> {
|
|||
|
||||
def DivFOp : FloatArithmeticOp<"divf"> {
|
||||
let summary = "floating point division operation";
|
||||
let hasFolder = 1;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -1483,6 +1483,15 @@ void DimOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
|
|||
DimOfCastOp<tensor::CastOp>>(context);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// DivFOp
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
OpFoldResult DivFOp::fold(ArrayRef<Attribute> operands) {
|
||||
return constFoldBinaryOp<FloatAttr>(
|
||||
operands, [](APFloat a, APFloat b) { return a / b; });
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// DmaStartOp
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue