[Mlir-commits] [mlir] [mlir] IntegerRangeAnalysis: add support for vector type (PR #112292)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Mon Oct 28 10:30:39 PDT 2024
================
@@ -35,10 +35,27 @@ convertArithOverflowFlags(arith::IntegerOverflowFlags flags) {
void arith::ConstantOp::inferResultRanges(ArrayRef<ConstantIntRanges> argRanges,
SetIntRangeFn setResultRange) {
- auto constAttr = llvm::dyn_cast_or_null<IntegerAttr>(getValue());
- if (constAttr) {
+ if (auto constAttr = llvm::dyn_cast_or_null<IntegerAttr>(getValue())) {
const APInt &value = constAttr.getValue();
setResultRange(getResult(), ConstantIntRanges::constant(value));
+ return;
+ }
+ if (auto constAttr =
+ llvm::dyn_cast_or_null<DenseIntElementsAttr>(getValue())) {
+ std::optional<ConstantIntRanges> result;
+ for (APInt &&val : constAttr) {
+ auto range = ConstantIntRanges::constant(val);
+ if (!result) {
----------------
banach-space wrote:
Wouldn't this work?
```suggestion
result = (result) ? result->rangeUnion(range) : range;
```
https://github.com/llvm/llvm-project/pull/112292
More information about the Mlir-commits
mailing list