Skip to content

Commit cb472fb

Browse files
author
Andy Kaylor
authored
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.
1 parent 852bac4 commit cb472fb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/lib/Transforms/Utils/SimplifyIndVar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ bool SimplifyIndvar::replaceFloatIVWithIntegerIV(Instruction *UseInst) {
664664
MaskBits = SE->getSignedRange(IV).getMinSignedBits();
665665
else
666666
MaskBits = SE->getUnsignedRange(IV).getActiveBits();
667-
unsigned DestNumSigBits = UseInst->getType()->getFPMantissaWidth();
667+
int DestNumSigBits = UseInst->getType()->getFPMantissaWidth();
668668
if (MaskBits <= DestNumSigBits) {
669669
for (User *U : UseInst->users()) {
670670
// Match for fptosi/fptoui of sitofp and with same type.

0 commit comments

Comments
 (0)