Skip to content

Commit aa13a08

Browse files
committed
Move assert before early return
1 parent 9f2efed commit aa13a08

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

mlir/lib/Dialect/Arith/IR/InferIntRangeInterfaceImpls.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "mlir/Interfaces/InferIntRangeInterface.h"
1111
#include "mlir/Interfaces/Utils/InferIntRangeCommon.h"
1212

13-
#include "llvm/ADT/STLExtras.h"
1413
#include "llvm/Support/Debug.h"
1514
#include <optional>
1615

@@ -43,6 +42,7 @@ void arith::ConstantOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
4342
}
4443
if (auto arrayCstAttr =
4544
llvm::dyn_cast_or_null<DenseIntElementsAttr>(getValue())) {
45+
assert(arrayCstAttr.size() && "Zero-sized vectors are not allowed");
4646
if (arrayCstAttr.isSplat()) {
4747
setResultRange(getResult(), ConstantIntRanges::constant(
4848
arrayCstAttr.getSplatValue<APInt>()));
@@ -55,7 +55,6 @@ void arith::ConstantOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
5555
result = (result ? result->rangeUnion(range) : range);
5656
}
5757

58-
assert(result && "Zero-sized vectors are not allowed");
5958
setResultRange(getResult(), *result);
6059
return;
6160
}

0 commit comments

Comments
 (0)