19
19
#include " mlir/Dialect/Affine/IR/AffineOps.h"
20
20
#include " mlir/Dialect/Affine/IR/AffineValueMap.h"
21
21
#include " mlir/Dialect/Arith/IR/Arith.h"
22
+ #include " mlir/Dialect/Linalg/IR/Linalg.h"
22
23
#include " mlir/Dialect/Utils/StaticValueUtils.h"
23
24
#include " mlir/IR/IntegerSet.h"
24
25
#include " mlir/Interfaces/CallInterfaces.h"
@@ -252,6 +253,9 @@ bool MemRefDependenceGraph::init() {
252
253
// Create graph nodes.
253
254
DenseMap<Operation *, unsigned > forToNodeMap;
254
255
for (Operation &op : block) {
256
+ bool hasUnsupportedRegion =
257
+ op.getNumRegions () != 0 &&
258
+ !isa<RegionBranchOpInterface, linalg::LinalgOp>(op);
255
259
if (auto forOp = dyn_cast<AffineForOp>(op)) {
256
260
Node *node = addNodeToMDG (&op, *this , memrefAccesses);
257
261
if (!node)
@@ -277,8 +281,7 @@ bool MemRefDependenceGraph::init() {
277
281
Node *node = addNodeToMDG (&op, *this , memrefAccesses);
278
282
if (!node)
279
283
return false ;
280
- } else if (!isMemoryEffectFree (&op) &&
281
- (op.getNumRegions () == 0 || isa<RegionBranchOpInterface>(op))) {
284
+ } else if (!isMemoryEffectFree (&op) && !hasUnsupportedRegion) {
282
285
// Create graph node for top-level op unless it is known to be
283
286
// memory-effect free. This covers all unknown/unregistered ops,
284
287
// non-affine ops with memory effects, and region-holding ops with a
@@ -287,7 +290,7 @@ bool MemRefDependenceGraph::init() {
287
290
Node *node = addNodeToMDG (&op, *this , memrefAccesses);
288
291
if (!node)
289
292
return false ;
290
- } else if (op. getNumRegions () != 0 && !isa<RegionBranchOpInterface>(op) ) {
293
+ } else if (hasUnsupportedRegion ) {
291
294
// Return false if non-handled/unknown region-holding ops are found. We
292
295
// won't know what such ops do or what its regions mean; for e.g., it may
293
296
// not be an imperative op.
0 commit comments