[llvm] [ValueTracking] Add a special overflow check on multiplied by power-of-two values (PR #212594)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 29 07:39:07 PDT 2026
================
@@ -7542,6 +7542,23 @@ OverflowResult llvm::computeOverflowForSignedMul(const Value *LHS,
if (LHSKnown.isNonNegative() || RHSKnown.isNonNegative())
return OverflowResult::NeverOverflows;
}
+
+ // Special case when we're multiplying a power-of-two value. In this case,
+ // we will never overflow as long as the shift amount is less than the number
+ // of sign bits.
+ if (isKnownToBeAPowerOfTwo(RHS, /*OrZero=*/false, SQ)) {
----------------
dtcxzyw wrote:
Does the motivating case contain a variable RHS? Can we just handle the constant RHS case?
https://github.com/llvm/llvm-project/pull/212594
More information about the llvm-commits
mailing list