Skip to content

Commit a8d0cb4

Browse files
committed
[mlir] IntegerRangeAnalysis: don't loop over splat attr
1 parent cd022b7 commit a8d0cb4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ void arith::ConstantOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
4242
}
4343
if (auto arrayCstAttr =
4444
llvm::dyn_cast_or_null<DenseIntElementsAttr>(getValue())) {
45+
if (arrayCstAttr.isSplat()) {
46+
setResultRange(getResult(), ConstantIntRanges::constant(
47+
arrayCstAttr.getSplatValue<APInt>()));
48+
return;
49+
}
50+
4551
std::optional<ConstantIntRanges> result;
4652
for (const APInt &val : arrayCstAttr) {
4753
auto range = ConstantIntRanges::constant(val);

0 commit comments

Comments
 (0)