diff options
author | Andy Kaylor <andrew.kaylor@intel.com> | 2023-10-20 15:23:45 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-20 15:23:45 -0700 |
commit | cb472fbd47b7e54796197ec272b8fc1f136466fc (patch) | |
tree | 9a1f0c25b07bb20f88b26298bdb3e6b7cb7dd621 /llvm/lib/Transforms/Utils/SimplifyIndVar.cpp | |
parent | 852bac4439010a479fb141942f2d3f1ff503996f (diff) | |
download | llvm-cb472fbd47b7e54796197ec272b8fc1f136466fc.zip llvm-cb472fbd47b7e54796197ec272b8fc1f136466fc.tar.gz llvm-cb472fbd47b7e54796197ec272b8fc1f136466fc.tar.bz2 |
Update SimplifyIndVar.cpp (#69760)
In SimplifyIndvar::replaceFloatIVWithIntegerIV() the return value of
getFPMantissaWidth() was being cast as an unsigned integer and then
compared with the number of bits needed to represent an integer that was
cast to and from a floating-point type. This is a problem because
getFPMantissaWidth() returns -1 if the type does not have a stable
mantissa.
Currently the only type that returns -1 is ppc_fp128, so you'd need a
pretty big induction variable to cause a problem. However, this problem
will be more likely to be exposed when we implement support for decimal
floating-point types.
Strictly speaking, what we want to know here is the size of the biggest
integer that can be represented exactly. We could get that information
even with an unstable mantissa width, but getFPMantissaWidth() won't do
it.
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyIndVar.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyIndVar.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp index 1caf708..45cbdd2 100644 --- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp @@ -664,7 +664,7 @@ bool SimplifyIndvar::replaceFloatIVWithIntegerIV(Instruction *UseInst) { MaskBits = SE->getSignedRange(IV).getMinSignedBits(); else MaskBits = SE->getUnsignedRange(IV).getActiveBits(); - unsigned DestNumSigBits = UseInst->getType()->getFPMantissaWidth(); + int DestNumSigBits = UseInst->getType()->getFPMantissaWidth(); if (MaskBits <= DestNumSigBits) { for (User *U : UseInst->users()) { // Match for fptosi/fptoui of sitofp and with same type. |