[llvm] 1c61acc - [CodeGen] Fix signed int overflow
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Tue May 2 12:58:21 PDT 2023
Author: Vitaly Buka
Date: 2023-05-02T12:58:07-07:00
New Revision: 1c61accbde8b6b2d18d023955dea93b2e27cfb0b
URL: https://github.com/llvm/llvm-project/commit/1c61accbde8b6b2d18d023955dea93b2e27cfb0b
DIFF: https://github.com/llvm/llvm-project/commit/1c61accbde8b6b2d18d023955dea93b2e27cfb0b.diff
LOG: [CodeGen] Fix signed int overflow
Exposed by the test from 8f966cedea594d9a91e585e88a80a42c04049e6c.
Added:
Modified:
llvm/include/llvm/CodeGen/TargetLowering.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h
index 7ea798027ef6..56a067a7bbae 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -2298,11 +2298,11 @@ class TargetLoweringBase {
/// considered beneficial.
/// If optimizing for size, expansion is only considered beneficial for upto
/// 5 multiplies and a divide (if the exponent is negative).
- bool isBeneficialToExpandPowI(int Exponent, bool OptForSize) const {
+ bool isBeneficialToExpandPowI(int64_t Exponent, bool OptForSize) const {
if (Exponent < 0)
Exponent = -Exponent;
- return !OptForSize ||
- (llvm::popcount((unsigned int)Exponent) + Log2_32(Exponent) < 7);
+ uint64_t E = static_cast<uint64_t>(Exponent);
+ return !OptForSize || (llvm::popcount(E) + Log2_64(E) < 7);
}
//===--------------------------------------------------------------------===//
More information about the llvm-commits
mailing list