[Mlir-commits] [mlir] 04ca53e - [mlir][SCF] Avoid linear scans when querying forall buffer aliases (#231187)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Oct 13 19:52:26 PDT 2026


Author: Akun
Date: 2026-10-14T11:52:21+09:00
New Revision: 04ca53e65fb234695323008abe2ef10c7cd13b1c

URL: https://github.com/llvm/llvm-project/commit/04ca53e65fb234695323008abe2ef10c7cd13b1c
DIFF: https://github.com/llvm/llvm-project/commit/04ca53e65fb234695323008abe2ef10c7cd13b1c.diff

LOG: [mlir][SCF] Avoid linear scans when querying forall buffer aliases (#231187)

Override `getAliasingOpOperands` for `scf.forall` to directly look up
the tied `shared_outs` operand.

The default implementation scans all tensor operands on each query,
making alias lookup quadratic when querying all results. Direct lookup
reduces this to linear overall, improving bufferization time for loops
with many shared outputs.

Added: 
    

Modified: 
    mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp b/mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp
index dad79b19f949a..35357b150e60f 100644
--- a/mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/SCF/Transforms/BufferizableOpInterfaceImpl.cpp
@@ -1230,6 +1230,16 @@ struct ForallOpInterface
         {{forallOp.getTiedOpResult(&opOperand), BufferRelation::Equivalent}}};
   }
 
+  AliasingOpOperandList
+  getAliasingOpOperands(Operation *op, Value value,
+                        const AnalysisState &state) const {
+    auto result = dyn_cast<OpResult>(value);
+    if (!result)
+      return {};
+    auto forallOp = cast<ForallOp>(op);
+    return {{forallOp.getTiedOpOperand(result), BufferRelation::Equivalent}};
+  }
+
   bool isWritable(Operation *op, Value value,
                   const AnalysisState &state) const {
     return true;


        


More information about the Mlir-commits mailing list