20#define GEN_PASS_DEF_MATHUPLIFTTOFMA
21#include "mlir/Dialect/Math/Transforms/Passes.h.inc"
28 return static_cast<bool>(op.getFastmath() & arith::FastMathFlags::contract);
36 LogicalResult matchAndRewrite(arith::AddFOp op,
37 PatternRewriter &rewriter)
const override {
43 if ((ab = op.getLhs().getDefiningOp<arith::MulFOp>())) {
45 }
else if ((ab = op.getRhs().getDefiningOp<arith::MulFOp>())) {
54 Value a = ab.getLhs();
55 Value
b = ab.getRhs();
56 arith::FastMathFlags fmf = op.getFastmath() & ab.getFastmath();
62struct MathUpliftToFMA final
64 using MathUpliftToFMABase::MathUpliftToFMABase;
66 void runOnOperation()
override {
70 return signalPassFailure();
static bool isValidForFMA(Op op)
This provides public APIs that all operations should have.
std::enable_if_t<!std::is_convertible< CallbackT, Twine >::value, LogicalResult > notifyMatchFailure(Location loc, CallbackT &&reasonCallback)
Used to notify the listener that the IR failed to be rewritten because of a match failure,...
OpTy replaceOpWithNewOp(Operation *op, Args &&...args)
Replace the results of the given (original) op with a new op that is created without verification (re...
Include the generated interface declarations.
LogicalResult applyPatternsGreedily(Region ®ion, const FrozenRewritePatternSet &patterns, GreedyRewriteConfig config=GreedyRewriteConfig(), bool *changed=nullptr)
Rewrite ops in the given region, which must be isolated from above, by repeatedly applying the highes...
void populateUpliftToFMAPatterns(RewritePatternSet &patterns)
const FrozenRewritePatternSet & patterns
OpRewritePattern is a wrapper around RewritePattern that allows for matching and rewriting against an...
OpRewritePattern(MLIRContext *context, PatternBenefit benefit=1, ArrayRef< StringRef > generatedNames={})
Patterns must specify the root operation name they match against, and can also specify the benefit of...