Skip to content

Commit ded3644

Browse files
committed
[MLIR][NFC] Fix a checked after used case in ReshapeOpsUtils.cpp
Found by PVS-Studio - https://pvs-studio.com/en/blog/posts/cpp/1003/, N18. The value of the 'sourceDim' index is checked after it was used. Reviewed By: zero9178 Differential Revision: https://reviews.llvm.org/D142312
1 parent 77f4c91 commit ded3644

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ mlir::getReassociationIndicesForCollapse(ArrayRef<int64_t> sourceShape,
4747
break;
4848

4949
int64_t currTargetShape = targetShape[targetDim];
50-
while (sourceShape[sourceDim] != ShapedType::kDynamic &&
51-
prodOfCollapsedDims * sourceShape[sourceDim] < currTargetShape &&
52-
sourceDim < sourceShape.size()) {
50+
while (sourceDim < sourceShape.size() &&
51+
sourceShape[sourceDim] != ShapedType::kDynamic &&
52+
prodOfCollapsedDims * sourceShape[sourceDim] < currTargetShape) {
5353
prodOfCollapsedDims *= sourceShape[sourceDim];
5454
currIndices.push_back(sourceDim++);
5555
}

0 commit comments

Comments
 (0)