File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -4873,6 +4873,22 @@ struct AffineBufferElimination : public OpRewritePattern<T> {
4873
4873
}
4874
4874
};
4875
4875
4876
+ struct MulDivMul : public OpRewritePattern <arith::MulIOp> {
4877
+ using OpRewritePattern<MulIOp>::OpRewritePattern;
4878
+ LogicalResult matchAndRewrite (MulIOp op,
4879
+ PatternRewriter &rewriter) const override {
4880
+ if (auto div = op.getLhs ().getDefiningOp <arith::DivUIOp>()) {
4881
+ if (auto mul = div.getLhs ().getDefiningOp <arith::MulIOp>()) {
4882
+ if (op.getRhs () == div.getRhs () && mul.getRhs () == op.getRhs ()) {
4883
+ rewriter.replaceOp (op, mul->getResults ());
4884
+ return success ();
4885
+ }
4886
+ }
4887
+ }
4888
+ return failure ();
4889
+ }
4890
+ };
4891
+
4876
4892
void TypeAlignOp::getCanonicalizationPatterns (RewritePatternSet &results,
4877
4893
MLIRContext *context) {
4878
4894
results.insert <
@@ -4889,6 +4905,7 @@ void TypeAlignOp::getCanonicalizationPatterns(RewritePatternSet &results,
4889
4905
AffineBufferElimination<memref::AllocOp>,
4890
4906
SimplifyDeadAllocV2<memref::AllocaOp>,
4891
4907
SimplifyDeadAllocV2<memref::AllocOp>, SimplifyDeadAllocV2<LLVM::AllocaOp>,
4908
+ MulDivMul,
4892
4909
// RankReduction<memref::AllocaOp, scf::ParallelOp>,
4893
4910
AggressiveAllocaScopeInliner, InductiveVarRemoval>(context);
4894
4911
}
You can’t perform that action at this time.
0 commit comments