Skip to content

Commit 9f2efed

Browse files
committed
IntegerRangeAnalysis: dont loop over splat attr
1 parent a6637ae commit 9f2efed

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

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

13+
#include "llvm/ADT/STLExtras.h"
1314
#include "llvm/Support/Debug.h"
1415
#include <optional>
1516

@@ -42,6 +43,12 @@ void arith::ConstantOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
4243
}
4344
if (auto arrayCstAttr =
4445
llvm::dyn_cast_or_null<DenseIntElementsAttr>(getValue())) {
46+
if (arrayCstAttr.isSplat()) {
47+
setResultRange(getResult(), ConstantIntRanges::constant(
48+
arrayCstAttr.getSplatValue<APInt>()));
49+
return;
50+
}
51+
4552
std::optional<ConstantIntRanges> result;
4653
for (const APInt &val : arrayCstAttr) {
4754
auto range = ConstantIntRanges::constant(val);

0 commit comments

Comments
 (0)