[flang-commits] [flang] [mlir] [mlir] Handle simple commutative cases in CSE. (PR #75274)
Jacques Pienaar via flang-commits
flang-commits at lists.llvm.org
Thu Dec 14 10:33:50 PST 2023
================
@@ -683,8 +683,17 @@ llvm::hash_code OperationEquivalence::computeHash(
hash = llvm::hash_combine(hash, op->getLoc());
// - Operands
- for (Value operand : op->getOperands())
- hash = llvm::hash_combine(hash, hashOperands(operand));
+ if (op->hasTrait<mlir::OpTrait::IsCommutative>() &&
+ op->getNumOperands() > 0) {
+ // If commutative, don't hash the operands as hash is not order independent
+ // and even if it were would not be sufficient for CSE usage.
+ // FIXME: This has the effect of resulting in more hash collisions
----------------
jpienaar wrote:
(this was sufficient for my test case, not the best symmetric merge, but I think good enough)
https://github.com/llvm/llvm-project/pull/75274
More information about the flang-commits
mailing list