Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

Add a method to apply specified patterns alone - only on the matching ops? #199

Open
bondhugula opened this issue Oct 18, 2019 · 2 comments

Comments

@bondhugula
Copy link
Contributor

It doesn't look like there is a way to apply a specific rewrite pattern in isolation, i.e., without triggering folding and dead code elimination everywhere in the op (its regions), which would include processing ops that don't match and have nothing to do with the specified pattern rewrites. Would it be meaningful to have a flag on applyPatternsGreedily or another version of it that instead will not perform any unrelated folding and dead code elimination? (It can of course remove any ops that become dead as a result of the specified pattern rewrites). The issue here is really the logic of GreedyPatternRewriteDriver::simplify(...).

bool GreedyPatternRewriteDriver::simplify(MutableArrayRef<Region> regions,

Having such a version is necessary to easily write test cases for specific patterns, and to be more efficient with the rewriting (not rewrite large parts of the IR unrelated to the pattern rewrites that have been supplied to the driver) -- this is especially the case when called on the function ops (most common) or ops with regions.

@joker-eph
Copy link
Contributor

If you have a use-case for it, what about adding a flag/option on the GreedyPatternRewriteDriver to not fold?

@bondhugula
Copy link
Contributor Author

If you have a use-case for it, what about adding a flag/option on the GreedyPatternRewriteDriver to not fold?

We actually want it to fold (and eliminate dead ops), but only in conjunction with the matched patterns. The issue is that it adds all ops (under the supplied op) to the worklist irrespective of whether they'll be matched.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants