[Mlir-commits] [mlir] [mlir][CSE] Introduce DialectInterface for CSE (PR #73520)

Jeff Niu llvmlistbot at llvm.org
Tue Nov 28 11:10:34 PST 2023


================
@@ -35,8 +35,16 @@ using namespace mlir;
 namespace {
 struct SimpleOperationInfo : public llvm::DenseMapInfo<Operation *> {
   static unsigned getHashValue(const Operation *opC) {
+    auto *op = const_cast<Operation *>(opC);
+    // Use a custom hook if provided.
+    if (auto *interface = dyn_cast<DialectCSEInterface>(op->getDialect())) {
+      std::optional<unsigned> val = interface->getHashValue(op);
----------------
Mogball wrote:

I think a better way to structure this implementation would be to have CSE only query the dialect interface, and have a default implementation of the dialect interface that uses operation equivalence. That also means other users of the interface don't need to know the fallback behaviour.

https://github.com/llvm/llvm-project/pull/73520


More information about the Mlir-commits mailing list