This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Fix worklist bug in MultiOpPatternRewriteDriver
ClosedPublic

Authored by springerm on Jan 6 2023, 9:07 AM.

Details

Summary

When strict = true, only pre-existing and newly-created ops are rewritten and/or folded. Such ops are stored in strictModeFilteredOps.

/// Applies the specified rewrite patterns on `ops` while also trying to fold
/// these ops as well as any other ops that were in turn created due to such
/// rewrites. [...]
bool applyOpPatternsAndFold(...);

Newly-created ops were previously added to strictModeFilteredOps after calling addToWorklist (via GreedyPatternRewriteDriver::notifyOperationInserted). Therefore, newly-created ops were never added to the worklist.

Also fix a test case that should have gone into an infinite loop (test.replace_with_new_op was replaced with itself, which should have caused the op to be rewritten over and over), but did not due to this bug.

Related Revision: https://reviews.llvm.org/D127180

Diff Detail

Event Timeline

springerm created this revision.Jan 6 2023, 9:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 6 2023, 9:07 AM
springerm requested review of this revision.Jan 6 2023, 9:07 AM
mehdi_amini accepted this revision.Jan 10 2023, 6:05 AM
This revision is now accepted and ready to land.Jan 10 2023, 6:05 AM
This revision was automatically updated to reflect the committed changes.