[flang-commits] [mlir] [flang] [mlir] Handle simple commutative cases in CSE. (PR #75274)
Mehdi Amini via flang-commits
flang-commits at lists.llvm.org
Wed Dec 13 22:51:25 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
----------------
joker-eph wrote:
If the only "based on the equivalence" aspect is the commutative, then @matthias-springer seems right to me?
Are you anticipating other criteria?
https://github.com/llvm/llvm-project/pull/75274
More information about the flang-commits
mailing list