diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td +++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td @@ -276,7 +276,7 @@ // AllocOp //===----------------------------------------------------------------------===// -def AllocOp : AllocLikeOp<"alloc"> { +def AllocOp : AllocLikeOp<"alloc", [MemoryEffects<[MemAlloc]>]> { let summary = "memory allocation operation"; let description = [{ The `alloc` operation allocates a region of memory, as specified by its diff --git a/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp b/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp --- a/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp +++ b/mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp @@ -38,9 +38,11 @@ if (v.isa()) return v; Operation *defOp = v.getDefiningOp(); - if (auto alloc = dyn_cast_or_null(defOp)) { - if (isStrided(alloc.getType())) - return alloc.getResult(); + if (auto allocEffect = dyn_cast_or_null(defOp)) { + if (allocEffect.hasEffect() && + defOp->getNumResults() == 1 && + isStrided(v.getType().cast())) + return v; } if (auto viewLikeOp = dyn_cast_or_null(defOp)) { auto it =