[llvm] [mlir] [AMDGPU][MLIR]Add shmem-optimization as an op using transform dialect (PR #81550)

Oleksandr Alex Zinenko via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 14 01:49:55 PST 2024


================
@@ -220,6 +218,20 @@ mlir::amdgpu::optimizeSharedMemoryReadsAndWrites(Operation *parentOp,
   return success();
 }
 
+void amdgpu::optimizeSharedMemoryReadsAndWritesOp(func::FuncOp funcOp) {
+  SmallVector<memref::AllocOp> shmAllocOps;
+  funcOp.walk([&](memref::AllocOp allocOp) {
+    if (!amdgpu::AMDGPUDialect::hasSharedMemoryAddressSpace(allocOp.getType()))
+      return;
+    shmAllocOps.push_back(allocOp);
+  });
+  for (auto allocOp : shmAllocOps) {
+    if (failed(amdgpu::optimizeSharedMemoryReadsAndWrites(funcOp,
+                                                          allocOp.getMemref())))
+      return;
+  }
+}
----------------
ftynse wrote:

It is rather strange to stop error propagation here and happily exit the transform when only part of the optimization happened. It looks preferable to return `failure()` from here and reported that as a silenceable error in the transform op. Even better if a specific failure message can be propagated.

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


More information about the llvm-commits mailing list