[llvm] [ConstantRange][LVI] Add initial support for `multiplyWithNoWrap` (PR #92356)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Thu May 16 02:15:52 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);
----------------
antoniofrighetto wrote:
Compile-time impact looks OK: http://llvm-compile-time-tracker.com/compare.php?from=cd5ee2715e89ad31982f91cc85fc3939977f2f4e&to=ce8d711be479a67c59a3079110ba2a2ea3d37434&stat=instructions:u.
https://github.com/llvm/llvm-project/pull/92356
More information about the llvm-commits
mailing list