[llvm] [ConstantRange][LVI] Add initial support for `multiplyWithNoWrap` (PR #92356)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Thu May 16 00:18:16 PDT 2024
================
@@ -1167,6 +1169,28 @@ ConstantRange::multiply(const ConstantRange &Other) const {
return UR.isSizeStrictlySmallerThan(SR) ? UR : SR;
}
+ConstantRange
+ConstantRange::multiplyWithNoWrap(const ConstantRange &Other,
+ unsigned NoWrapKind,
+ PreferredRangeType RangeType) const {
+ if (isEmptySet() || Other.isEmptySet())
+ return getEmpty();
+
+ ConstantRange Result = multiply(Other);
+
+ // TODO: Bounds are not yet precise if the input sets are non-wrapped /
+ // non-sign-wrapped, as we may still conservatively return full-set in such
+ // cases. To be extended.
+
+ if (NoWrapKind & OverflowingBinaryOperator::NoSignedWrap)
+ Result = Result.intersectWith(smul_sat(Other), RangeType);
----------------
dtcxzyw wrote:
@nikic Can you test the compile-time impact?
https://github.com/llvm/llvm-project/pull/92356
More information about the llvm-commits
mailing list