[MemRef] Remove memref.dim OffsetSizeAndStrideOpInterface folding (#169327)
OffsetSizeAndStrideOpInterface does not specify whether it's operating on the input or output shape and in fact different ops implement this in different ways, which is also why SubviewOp is special cased here. This "marked as dynamic but not really dynamic" folding is better handled by shape inference, so just remove the bad fold.
This commit is contained in:
parent
ba98668dca
commit
4650f8521d
@ -1074,13 +1074,6 @@ OpFoldResult DimOp::fold(FoldAdaptor adaptor) {
|
||||
return subview.getDynamicSize(sourceIndex);
|
||||
}
|
||||
|
||||
if (auto sizeInterface =
|
||||
dyn_cast_or_null<OffsetSizeAndStrideOpInterface>(definingOp)) {
|
||||
assert(sizeInterface.isDynamicSize(unsignedIndex) &&
|
||||
"Expected dynamic subview size");
|
||||
return sizeInterface.getDynamicSize(unsignedIndex);
|
||||
}
|
||||
|
||||
// dim(memrefcast) -> dim
|
||||
if (succeeded(foldMemRefCast(*this)))
|
||||
return getResult();
|
||||
|
||||
@ -208,19 +208,6 @@ func.func @subview_negative_stride2(%arg0 : memref<7xf32>) -> memref<?xf32, stri
|
||||
|
||||
// -----
|
||||
|
||||
// CHECK-LABEL: func @dim_of_sized_view
|
||||
// CHECK-SAME: %{{[a-z0-9A-Z_]+}}: memref<?xi8>
|
||||
// CHECK-SAME: %[[SIZE:.[a-z0-9A-Z_]+]]: index
|
||||
// CHECK: return %[[SIZE]] : index
|
||||
func.func @dim_of_sized_view(%arg : memref<?xi8>, %size: index) -> index {
|
||||
%c0 = arith.constant 0 : index
|
||||
%0 = memref.reinterpret_cast %arg to offset: [0], sizes: [%size], strides: [1] : memref<?xi8> to memref<?xi8>
|
||||
%1 = memref.dim %0, %c0 : memref<?xi8>
|
||||
return %1 : index
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
// CHECK-LABEL: func @no_fold_subview_negative_size
|
||||
// CHECK: %[[SUBVIEW:.+]] = memref.subview
|
||||
// CHECK: return %[[SUBVIEW]]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user