[Mlir-commits] [mlir] [mlir][IntegerRangeAnalysis] Handle multi-dimensional loops (PR #170765)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Fri Dec 5 00:19:08 PST 2025
================
@@ -180,23 +180,20 @@ void IntegerRangeAnalysis::visitNonControlFlowArguments(
return;
}
- /// Given the results of getConstant{Lower,Upper}Bound() or getConstantStep()
- /// on a LoopLikeInterface return the lower/upper bound for that result if
- /// possible.
+ /// Given a lower bound, upper bound, or step from aLoopLikeInterface return
+ /// the lower/upper bound for that result if possible.
auto getLoopBoundFromFold = [&](std::optional<OpFoldResult> loopBound,
Type boundType, Block *block, bool getUpper) {
unsigned int width = ConstantIntRanges::getStorageBitwidth(boundType);
- if (loopBound.has_value()) {
- if (auto attr = dyn_cast<Attribute>(*loopBound)) {
- if (auto bound = dyn_cast_or_null<IntegerAttr>(attr))
- return bound.getValue();
- } else if (auto value = llvm::dyn_cast_if_present<Value>(*loopBound)) {
- const IntegerValueRangeLattice *lattice =
- getLatticeElementFor(getProgramPointBefore(block), value);
- if (lattice != nullptr && !lattice->getValue().isUninitialized())
- return getUpper ? lattice->getValue().getValue().smax()
- : lattice->getValue().getValue().smin();
- }
+ if (auto attr = dyn_cast<Attribute>(*loopBound)) {
+ if (auto bound = dyn_cast_or_null<IntegerAttr>(attr))
+ return bound.getValue();
+ } else if (auto value = llvm::dyn_cast_if_present<Value>(*loopBound)) {
----------------
ftynse wrote:
Can `OpFoldResult` ever be null in this context? If so, the `if` condition above should also handle this.
https://github.com/llvm/llvm-project/pull/170765
More information about the Mlir-commits
mailing list