[Mlir-commits] [mlir] 04481f2 - [mlir] Require std.alloc() ops to have canonical layout during LLVM lowering.

Christian Sigg llvmlistbot at llvm.org
Mon Nov 16 08:29:46 PST 2020


Author: Christian Sigg
Date: 2020-11-16T17:29:36+01:00
New Revision: 04481f26faff79027192bd27200956be16c11102

URL: https://github.com/llvm/llvm-project/commit/04481f26faff79027192bd27200956be16c11102
DIFF: https://github.com/llvm/llvm-project/commit/04481f26faff79027192bd27200956be16c11102.diff

LOG: [mlir] Require std.alloc() ops to have canonical layout during LLVM lowering.

The current code allows strided layouts, but the number of elements allocated is ambiguous. It could be either the number of elements in the shape (the current implementation), or the amount of elements required to not index out-of-bounds with the given maps (which would require evaluating the layout map).

If we require the canonical layouts, the two will be the same.

Reviewed By: nicolasvasilache, ftynse

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

Added: 
    

Modified: 
    mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
    mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
index 6807f8311e7c..d70a61261cb2 100644
--- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
+++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
@@ -1987,21 +1987,7 @@ struct AllocLikeOpLowering : public ConvertToLLVMPattern {
 
   LogicalResult match(Operation *op) const override {
     MemRefType memRefType = getMemRefResultType(op);
-    if (isSupportedMemRefType(memRefType))
-      return success();
-
-    int64_t offset;
-    SmallVector<int64_t, 4> strides;
-    if (failed(getStridesAndOffset(memRefType, strides, offset)))
-      return failure();
-
-    // Dynamic strides are ok if they can be deduced from dynamic sizes (which
-    // is guaranteed when getStridesAndOffset succeeded. Dynamic offset however
-    // can never be alloc'ed.
-    if (offset == MemRefType::getDynamicStrideOrOffset())
-      return failure();
-
-    return success();
+    return success(isSupportedMemRefType(memRefType));
   }
 
   // An `alloc` is converted into a definition of a memref descriptor value and

diff  --git a/mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir b/mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir
index 0c38d02e816a..e4a4a434142c 100644
--- a/mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir
+++ b/mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir
@@ -10,12 +10,6 @@ func @address_space(%arg0 : memref<32xf32, affine_map<(d0) -> (d0)>, 7>) {
   std.return
 }
 
-// CHECK-LABEL: func @strided_memref(
-func @strided_memref(%ind: index) {
-  %0 = alloc()[%ind] : memref<32x64xf32, affine_map<(i, j)[M] -> (32 + M * i + j)>>
-  std.return
-}
-
 // -----
 
 // CHECK-LABEL: func @rsqrt(


        


More information about the Mlir-commits mailing list