HomePhabricator

[MLIR] Fix op folding to not run pre-replace when not constant folding

Authored by bondhugula on Mon, Mar 16, 10:04 PM.

Description

[MLIR] Fix op folding to not run pre-replace when not constant folding

OperationFolder::tryToFold was running the pre-replacement
action even when there was no constant folding, i.e., when the operation
was just being updated in place but was not going to be replaced. This
led to nested ops being unnecessarily removed from the worklist and only
being processed in the next outer iteration of the greedy pattern
rewriter, which is also why this didn't affect the final output IR but
only the convergence rate. It also led to an op's results' users to be
unnecessarily added to the worklist.

Signed-off-by: Uday Bondhugula <uday@polymagelabs.com>

Differential Revision: https://reviews.llvm.org/D76268