OpRewritePattern pattern recognizer does not work on an operation with subregion

Hello.
I encountered problems with the mlir::OpRewritePattern pattern recognizer to recognize an operation when it has a subregion, defined in TableGen with:

     let regions = (region
        SizedRegion<1>:$op
    );
For me basically the operation is simply skipped and it seems the reason is it has a subregion.
Please help me solve this issue.

Thank you very much,
Alex

Have you tried running with -debug (in an assert build) to get more information?

An mlir::OpRewritePattern matches exclusively on the op name and nothing else. You’re responsible to implement manually any other checks, so if it does not apply it is because of something else.

Hello.
I solved the problem.
The reason was not the fact that the operation had a subregion, but simply the fact the respective operation with subregion was declared as legal (with a target.addLegalOp<>() instruction), so then the mlir::applyFullConversion() call was disregarding the respective MLIR operation deeming it already legal. More exactly, we can see when running the debug build of mlir-opt with -debug that it writes for the respective operation with subregion: “-> SUCCESS : operation marked legal by the target”.

Thank you very much,
Alex

1 Like