From 04481f26faff79027192bd27200956be16c11102 Mon Sep 17 00:00:00 2001 From: Christian Sigg Date: Mon, 16 Nov 2020 11:41:59 +0100 Subject: [PATCH] [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 --- .../Conversion/StandardToLLVM/StandardToLLVM.cpp | 16 +--------------- .../StandardToLLVM/standard-to-llvm.mlir | 6 ------ 2 files changed, 1 insertion(+), 21 deletions(-) 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 @@ private: LogicalResult match(Operation *op) const override { MemRefType memRefType = getMemRefResultType(op); - if (isSupportedMemRefType(memRefType)) - return success(); - - int64_t offset; - SmallVector 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(