aboutsummaryrefslogtreecommitdiff
path: root/mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp')
-rw-r--r--mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp b/mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp
index 7a73a94..1eab413 100644
--- a/mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp
+++ b/mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp
@@ -386,7 +386,15 @@ mlir::intrange::inferCeilDivS(ArrayRef<ConstantIntRanges> argRanges) {
}
return result;
};
- return inferDivSRange(lhs, rhs, ceilDivSIFix);
+ ConstantIntRanges result = inferDivSRange(lhs, rhs, ceilDivSIFix);
+ if (lhs.smin().isMinSignedValue() && lhs.smax().sgt(lhs.smin())) {
+ // If lhs range includes INT_MIN and lhs is not a single value, we can
+ // suddenly wrap to positive val, skipping entire negative range, add
+ // [INT_MIN + 1, smax()] range to the result to handle this.
+ auto newLhs = ConstantIntRanges::fromSigned(lhs.smin() + 1, lhs.smax());
+ result = result.rangeUnion(inferDivSRange(newLhs, rhs, ceilDivSIFix));
+ }
+ return result;
}
ConstantIntRanges