[Mlir-commits] [mlir] [mlir] fix IntegerRangeAnalysis::staticallyNonNegative (PR #134003)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Apr 1 16:12:21 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Maksim Levental (makslevental)
<details>
<summary>Changes</summary>
After https://github.com/llvm/llvm-project/pull/133541, `ConstantIntRanges` can sometimes have 0-bitwidth APInt. This leads to
```
llvm/include/llvm/ADT/APInt.h:1044: bool llvm::APInt::operator[](unsigned int) const: Assertion `bitPosition < getBitWidth() && "Bit position out of bounds!"' failed.
```
somewhere around here. This isn't a great fix (basically a band-aid) but I'm putting it up so we can centralize discussion of how to actually fix - possibly we might first revert https://github.com/llvm/llvm-project/pull/133541? Not sure.
---
Full diff: https://github.com/llvm/llvm-project/pull/134003.diff
1 Files Affected:
- (modified) mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp (+3)
``````````diff
diff --git a/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp b/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp
index c7a950d9a8871..6cbd83c8652e6 100644
--- a/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp
+++ b/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp
@@ -43,6 +43,9 @@ LogicalResult staticallyNonNegative(DataFlowSolver &solver, Value v) {
if (!result || result->getValue().isUninitialized())
return failure();
const ConstantIntRanges &range = result->getValue().getValue();
+ if (range.umin().getBitWidth() || range.umax().getBitWidth() ||
+ range.smin().getBitWidth() || range.smax().getBitWidth())
+ return false;
return success(range.smin().isNonNegative());
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/134003
More information about the Mlir-commits
mailing list