[llvm] [ConstantFolding] Handle large exponents in ldexp (PR #199309)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sat May 23 11:01:37 PDT 2026
================
@@ -3713,9 +3713,16 @@ static Constant *ConstantFoldIntrinsicCall2(Intrinsic::ID IntrinsicID, Type *Ty,
} else if (auto *Op2C = dyn_cast<ConstantInt>(Operands[1])) {
switch (IntrinsicID) {
case Intrinsic::ldexp: {
+ // APFloat::scalbn takes the exponent as `int`. Clamp wider integer
+ // exponents into [INT_MIN, INT_MAX] so values still saturate the
+ // result to +/-inf or +/-0.
+ int64_t Exp = Op2C->getSExtValue();
----------------
dtcxzyw wrote:
`getSExtValue` will assert when the value doesn't fit in an `int64_t`.
https://github.com/llvm/llvm-project/pull/199309
More information about the llvm-commits
mailing list