[Mlir-commits] [mlir] 7f44a71 - [MLIR] Set alignment in AllocOp of normalizeMemref()

Uday Bondhugula llvmlistbot at llvm.org
Wed Jul 22 00:08:20 PDT 2020


Author: Haruki Imai
Date: 2020-07-22T12:34:35+05:30
New Revision: 7f44a7130b9220cfd52e5c52eb1b7641c4ae7e95

URL: https://github.com/llvm/llvm-project/commit/7f44a7130b9220cfd52e5c52eb1b7641c4ae7e95
DIFF: https://github.com/llvm/llvm-project/commit/7f44a7130b9220cfd52e5c52eb1b7641c4ae7e95.diff

LOG: [MLIR] Set alignment in AllocOp of normalizeMemref()

AllocOp is updated in normalizeMemref(AllocOp allocOp), but, when the
AllocOp has `alignment` attribute, it was ignored and updated AllocOp
does not have `alignment` attribute. This patch fixes it.

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

Added: 
    

Modified: 
    mlir/lib/Transforms/Utils/Utils.cpp
    mlir/test/Transforms/memref-normalize.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Transforms/Utils/Utils.cpp b/mlir/lib/Transforms/Utils/Utils.cpp
index 5d6d58fc6939..35853c17232b 100644
--- a/mlir/lib/Transforms/Utils/Utils.cpp
+++ b/mlir/lib/Transforms/Utils/Utils.cpp
@@ -445,7 +445,9 @@ LogicalResult mlir::normalizeMemRef(AllocOp allocOp) {
       MemRefType::Builder(memrefType)
           .setShape(newShape)
           .setAffineMaps(b.getMultiDimIdentityMap(newRank));
-  auto newAlloc = b.create<AllocOp>(allocOp.getLoc(), newMemRefType);
+
+  auto newAlloc = b.create<AllocOp>(allocOp.getLoc(), newMemRefType, llvm::None,
+                                    allocOp.alignmentAttr());
 
   // Replace all uses of the old memref.
   if (failed(replaceAllMemRefUsesWith(oldMemRef, /*newMemRef=*/newAlloc,

diff  --git a/mlir/test/Transforms/memref-normalize.mlir b/mlir/test/Transforms/memref-normalize.mlir
index 6254899b1fe8..375bd3ef0e6c 100644
--- a/mlir/test/Transforms/memref-normalize.mlir
+++ b/mlir/test/Transforms/memref-normalize.mlir
@@ -143,3 +143,10 @@ func @semi_affine_layout_map(%s0: index, %s1: index) {
   }
   return
 }
+
+// CHECK-LABEL: func @alignment
+func @alignment() {
+  %A = alloc() {alignment = 32 : i64}: memref<64x128x256xf32, affine_map<(d0, d1, d2) -> (d2, d0, d1)>>
+  // CHECK-NEXT: alloc() {alignment = 32 : i64} : memref<256x64x128xf32>
+  return
+}


        


More information about the Mlir-commits mailing list