This is an archive of the discontinued LLVM Phabricator instance.

[mlir][IR] Implement proper folder for `IsCommutative` trait
ClosedPublic

Authored by springerm on Jul 19 2023, 2:46 AM.

Details

Summary

Commutative ops were previously folded with a special rule in OperationFolder. This change turns the folding into a proper OpTrait folder.

Diff Detail

Event Timeline

springerm created this revision.Jul 19 2023, 2:46 AM
Herald added a reviewer: dcaballe. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
springerm requested review of this revision.Jul 19 2023, 2:46 AM
mehdi_amini accepted this revision.Jul 19 2023, 11:44 AM
mehdi_amini added inline comments.
mlir/lib/IR/Operation.cpp
805

Can we make it llvm::find_if(op->getOpOperands(), isConstant); ?

This revision is now accepted and ready to land.Jul 19 2023, 11:44 AM
springerm marked an inline comment as done.Jul 20 2023, 1:14 AM
springerm added inline comments.
mlir/lib/IR/Operation.cpp
805

We could, but we still need isNotConstant to pass to std::stable_partition, so the way it is written at the moment is the fewest lines of code.

This revision was automatically updated to reflect the committed changes.
springerm marked an inline comment as done.