Skip to content

Commit ec039cd

Browse files
committed
Use SplatElementsAttr instead of isSplat
1 parent aa13a08 commit ec039cd

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,20 @@ void arith::ConstantOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
4040
setResultRange(getResult(), ConstantIntRanges::constant(value));
4141
return;
4242
}
43+
if (auto splatAttr = llvm::dyn_cast_or_null<SplatElementsAttr>(getValue())) {
44+
setResultRange(getResult(), ConstantIntRanges::constant(
45+
splatAttr.getSplatValue<APInt>()));
46+
return;
47+
}
4348
if (auto arrayCstAttr =
4449
llvm::dyn_cast_or_null<DenseIntElementsAttr>(getValue())) {
45-
assert(arrayCstAttr.size() && "Zero-sized vectors are not allowed");
46-
if (arrayCstAttr.isSplat()) {
47-
setResultRange(getResult(), ConstantIntRanges::constant(
48-
arrayCstAttr.getSplatValue<APInt>()));
49-
return;
50-
}
51-
5250
std::optional<ConstantIntRanges> result;
5351
for (const APInt &val : arrayCstAttr) {
5452
auto range = ConstantIntRanges::constant(val);
5553
result = (result ? result->rangeUnion(range) : range);
5654
}
5755

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

0 commit comments

Comments
 (0)