[Mlir-commits] [mlir] [flang] [mlir][Transforms] `GreedyPatternRewriteDriver`: Do not CSE constants during iterations (PR #75897)

Matthias Springer llvmlistbot at llvm.org
Thu Dec 21 22:07:54 PST 2023


================
@@ -273,7 +273,14 @@ DecomposeLinalgOp::matchAndRewrite(GenericOp genericOp,
 
   /// If the op has only a single statement (apart from the yield), do nothing.
   Block *body = genericOp.getBody();
-  if (body->getOperations().size() <= 2) {
+  int64_t numOps = 0;
+  for (Operation &op : body->getOperations()) {
----------------
matthias-springer wrote:

Yes.

The rewrite pattern here decomposes a LinalgOp into multiple LinalgOps with one nested op per decomposed op. The rewrite pattern sometimes materializes constants inside of the region. These are now no longer hoisted immediately, so the rewrite pattern is applied again and again (infinite loop). The hoisting now occurs at the beginning of a greedy pattern iteration, but there can be multiple pattern applications (of the same pattern) in one iteration.

The fix that I had here was not ideal. The issue in `DecomposeLinalgOps.cpp` is now fixed in a different way.


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


More information about the Mlir-commits mailing list