Page MenuHomePhabricator

[mlir][PDL] Infer result types from a `replace` as the last resort
ClosedPublic

Authored by rriddle on Sep 1 2022, 12:37 PM.

Details

Summary

This prevents situations where explicit results types were provided,
which have different types than the operation being replaced. This
is useful for supporting dialect conversion, which will have proper
support added in a followup.

Diff Detail

Event Timeline

rriddle created this revision.Sep 1 2022, 12:37 PM
rriddle requested review of this revision.Sep 1 2022, 12:37 PM

Would an unrealized cast be needed where the replaced op has different type? (I forget if that is automatically handled).

mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
888

This is optimistic check isn't it? E.g., if in a block dominated by this one it would allow it, so only skipping on cheap to check case.

Would an unrealized cast be needed where the replaced op has different type? (I forget if that is automatically handled).

Cast insertion is handled automatically by the rewriter (see the follow up commit for a test that has that).

mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
888

PDL rewrites only have single block regions, so if the op isn't in the rewriter block (i.e. the current block of the operation) we already know it dominates (i.e. it would be in the matcher).

jpienaar accepted this revision.Sep 4 2022, 4:03 PM
jpienaar added inline comments.
mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
888

Ah, could you expand comment in 885 to capture this?

This revision is now accepted and ready to land.Sep 4 2022, 4:03 PM
This revision was automatically updated to reflect the committed changes.
rriddle marked 2 inline comments as done.