Removing unused op results using PatternRewriter

Hi, I want to write canonicalization, which replaces some op with other op returning less results, if some results of the original op are unused. What is the correct way to do this using PatternRewriter? Can I call replaceOp with null values for unused results?

I want to say yes (given that this is how dialect conversion works). I thought that the base PatternRewriter was the same, but I can’t see asserts for use_empty on null anymore. We should update RewriterBase::replaceOp to check for that (passing null should already be fine, but we should assert that the value is use_empty when null is passed).

– River

1 Like