Skip to content

Commit f989905

Browse files
committed
review fixes
1 parent 8030aa9 commit f989905

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

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

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,21 @@ convertArithOverflowFlags(arith::IntegerOverflowFlags flags) {
3535

3636
void arith::ConstantOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
3737
SetIntRangeFn setResultRange) {
38-
if (auto constAttr = llvm::dyn_cast_or_null<IntegerAttr>(getValue())) {
39-
const APInt &value = constAttr.getValue();
38+
if (auto scalarCstAttr = llvm::dyn_cast_or_null<IntegerAttr>(getValue())) {
39+
const APInt &value = scalarCstAttr.getValue();
4040
setResultRange(getResult(), ConstantIntRanges::constant(value));
4141
return;
4242
}
43-
if (auto constAttr =
43+
if (auto arrayCstAttr =
4444
llvm::dyn_cast_or_null<DenseIntElementsAttr>(getValue())) {
4545
std::optional<ConstantIntRanges> result;
46-
for (APInt &&val : constAttr) {
46+
for (const APInt &val : arrayCstAttr) {
4747
auto range = ConstantIntRanges::constant(val);
48-
if (!result) {
49-
result = range;
50-
} else {
51-
result = result->rangeUnion(range);
52-
}
48+
result = (result ? result->rangeUnion(range) : range);
5349
}
5450

55-
if (result)
56-
setResultRange(getResult(), *result);
57-
51+
assert(result && "Zero-sized vectors are not allowed");
52+
setResultRange(getResult(), *result);
5853
return;
5954
}
6055
}

mlir/test/Dialect/Vector/int-range-interface.mlir

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ func.func @constant_splat() -> vector<8xi32> {
1717
func.return %1 : vector<8xi32>
1818
}
1919

20-
2120
// CHECK-LABEL: func @vector_splat
2221
// CHECK: test.reflect_bounds {smax = 5 : index, smin = 4 : index, umax = 5 : index, umin = 4 : index}
2322
func.func @vector_splat() -> vector<4xindex> {

0 commit comments

Comments
 (0)