Skip to content

Commit 1f5807e

Browse files
authored
[mlir][vector][nfc] Simplify in_bounds attr update (llvm#100334)
Since the `in_bounds` attribute is mandatory, there's no need for logic like this (`readOp.getInBounds()` is guaranteed to return a non-empty ArrayRef): ```cpp ArrayAttr inBoundsAttr = readOp.getInBounds() ? rewriter.getArrayAttr( readOp.getInBoundsAttr().getValue().drop_back(dimsToDrop)) : ArrayAttr(); ``` Instead, we can do this: ```cpp ArrayAttr inBoundsAttr = rewriter.getArrayAttr( readOp.getInBoundsAttr().getValue().drop_back(dimsToDrop)); ``` This is a small follow-up for llvm#97049 - this change should've been included there.
1 parent de8c4be commit 1f5807e

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp

+4-10
Original file line numberDiff line numberDiff line change
@@ -1321,11 +1321,8 @@ class DropInnerMostUnitDimsTransferRead
13211321
cast<MemRefType>(memref::SubViewOp::inferRankReducedResultType(
13221322
srcType.getShape().drop_back(dimsToDrop), srcType, offsets, sizes,
13231323
strides));
1324-
ArrayAttr inBoundsAttr =
1325-
readOp.getInBounds()
1326-
? rewriter.getArrayAttr(
1327-
readOp.getInBoundsAttr().getValue().drop_back(dimsToDrop))
1328-
: ArrayAttr();
1324+
ArrayAttr inBoundsAttr = rewriter.getArrayAttr(
1325+
readOp.getInBoundsAttr().getValue().drop_back(dimsToDrop));
13291326
Value rankedReducedView = rewriter.create<memref::SubViewOp>(
13301327
loc, resultMemrefType, readOp.getSource(), offsets, sizes, strides);
13311328
auto permMap = getTransferMinorIdentityMap(
@@ -1415,11 +1412,8 @@ class DropInnerMostUnitDimsTransferWrite
14151412
cast<MemRefType>(memref::SubViewOp::inferRankReducedResultType(
14161413
srcType.getShape().drop_back(dimsToDrop), srcType, offsets, sizes,
14171414
strides));
1418-
ArrayAttr inBoundsAttr =
1419-
writeOp.getInBounds()
1420-
? rewriter.getArrayAttr(
1421-
writeOp.getInBoundsAttr().getValue().drop_back(dimsToDrop))
1422-
: ArrayAttr();
1415+
ArrayAttr inBoundsAttr = rewriter.getArrayAttr(
1416+
writeOp.getInBoundsAttr().getValue().drop_back(dimsToDrop));
14231417

14241418
Value rankedReducedView = rewriter.create<memref::SubViewOp>(
14251419
loc, resultMemrefType, writeOp.getSource(), offsets, sizes, strides);

0 commit comments

Comments
 (0)