Skip to content

Commit 3deee23

Browse files
authored
[mlir] IntegerRangeAnalysis: don't loop over splat attr (#115229)
If the `DenseIntElementsAttr` is a splat value, there is no need to loop over the entire attr. Instead, just update with the splat value.
1 parent 64c9218 commit 3deee23

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ 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())) {
4550
std::optional<ConstantIntRanges> result;

0 commit comments

Comments
 (0)