[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

Jeff Niu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 20 21:10:58 PDT 2022


Mogball added inline comments.


================
Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:238
+    // Stores the mapping between an operand and its BFS traversal information.
+    DenseMap<Value, OperandBFS *> operandToItsBFSMap;
+
----------------
Why can't you sort the OperandBFS directly to avoid the hash map?


================
Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:286
+    for (unsigned i = 0, e = op->getNumOperands(); i < e; i++) {
+      OperandBFS *bfs = new OperandBFS();
+      bfs->pushAncestor(operands[i].getDefiningOp());
----------------
Can you use unique_ptr so that the memory doesn't leak?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124750/new/

https://reviews.llvm.org/D124750



More information about the cfe-commits mailing list