[mlir][scf] Create constants for tiling in parent with isolated region.
authorOleg Shyshkov <shyshkov@google.com>
Thu, 30 Mar 2023 21:18:21 +0000 (23:18 +0200)
committerOleg Shyshkov <shyshkov@google.com>
Fri, 31 Mar 2023 16:27:30 +0000 (18:27 +0200)
FuncOp is IsolatedFromAbove, so this change doesn't alter current behaviour, but the current code fails if the tile op is in an op with IsolatedFromAbove trait.

An alternative would be to create constant in the same region where they're used a rely on CSE to figure out where to move them.

Differential Revision: https://reviews.llvm.org/D147273

mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp

index ec116df..544a863 100644 (file)
@@ -37,7 +37,9 @@ scf::SCFTilingOptions::setTileSizes(ArrayRef<int64_t> ts) {
   tileSizeComputationFunction = [tileSizes](OpBuilder &b, Operation *op) {
     OpBuilder::InsertionGuard guard(b);
     b.setInsertionPointToStart(
-        &op->getParentOfType<func::FuncOp>().getBody().front());
+        &op->getParentWithTrait<OpTrait::IsIsolatedFromAbove>()
+             ->getRegion(0)
+             .front());
     return llvm::to_vector<4>(map_range(tileSizes, [&](int64_t s) {
       Value v = b.create<arith::ConstantIndexOp>(op->getLoc(), s);
       return v;