20 #define GEN_PASS_DEF_MATHUPLIFTTOFMA
21 #include "mlir/Dialect/Math/Transforms/Passes.h.inc"
26 template <
typename Op>
36 LogicalResult matchAndRewrite(arith::AddFOp op,
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();
62 struct MathUpliftToFMA final
63 : math::impl::MathUpliftToFMABase<MathUpliftToFMA> {
64 using MathUpliftToFMABase::MathUpliftToFMABase;
66 void runOnOperation()
override {
71 return signalPassFailure();
static MLIRContext * getContext(OpFoldResult val)
static void contract(RootOrderingGraph &graph, ArrayRef< Value > cycle, const DenseMap< Value, unsigned > &parentDepths, DenseMap< Value, Value > &actualSource, DenseMap< Value, Value > &actualTarget)
Contracts the specified cycle in the given graph in-place.
static bool isValidForFMA(Op op)
This provides public APIs that all operations should have.
A special type of RewriterBase that coordinates the application of a rewrite pattern on the current I...
RewritePatternSet & insert(ConstructorArg &&arg, ConstructorArgs &&...args)
Add an instance of each of the pattern types 'Ts' to the pattern list with the given arguments.
MLIRContext * getContext() const
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...
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Include the generated interface declarations.
void populateUpliftToFMAPatterns(RewritePatternSet &patterns)
LogicalResult applyPatternsAndFoldGreedily(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...
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...