In upstream mlir, the dialect conversion infrastructure is used for
lowering from one dialect to another: the passes are of the form
XToYPass. Whereas, transformations within the same dialect tend to use
applyPatternsAndFoldGreedily.
The Greedy Pattern Rewrite Driver is more convenient for this sort of
conversion because it lets the pattern decide if it matches, instead of
requiring ops to be marked as illegal (which is most convenient when
lowering from one dialect to another).
In this case, the full complexity of applyPatternsAndFoldGreedily is
not needed so we can get away with the simpler
applyOpPatternsAndFold.
This change was suggested by @jeanPerier
Shouldn't this be const? As I understand, pattern members must not be modified.