@@ -7294,14 +7294,14 @@ Instruction *InstCombinerImpl::foldFCmpIntToFPConst(FCmpInst &I,
7294
7294
int MantissaWidth = LHSI->getType ()->getFPMantissaWidth ();
7295
7295
if (MantissaWidth == -1 ) return nullptr ; // Unknown.
7296
7296
7297
- IntegerType *IntTy = cast<IntegerType>( LHSI->getOperand (0 )->getType () );
7298
-
7297
+ Type *IntTy = LHSI->getOperand (0 )->getType ();
7298
+ unsigned IntWidth = IntTy-> getScalarSizeInBits ();
7299
7299
bool LHSUnsigned = isa<UIToFPInst>(LHSI);
7300
7300
7301
7301
if (I.isEquality ()) {
7302
7302
FCmpInst::Predicate P = I.getPredicate ();
7303
7303
bool IsExact = false ;
7304
- APSInt RHSCvt (IntTy-> getBitWidth () , LHSUnsigned);
7304
+ APSInt RHSCvt (IntWidth , LHSUnsigned);
7305
7305
RHS.convertToInteger (RHSCvt, APFloat::rmNearestTiesToEven, &IsExact);
7306
7306
7307
7307
// If the floating point constant isn't an integer value, we know if we will
@@ -7326,23 +7326,22 @@ Instruction *InstCombinerImpl::foldFCmpIntToFPConst(FCmpInst &I,
7326
7326
// Check to see that the input is converted from an integer type that is small
7327
7327
// enough that preserves all bits. TODO: check here for "known" sign bits.
7328
7328
// This would allow us to handle (fptosi (x >>s 62) to float) if x is i64 f.e.
7329
- unsigned InputSize = IntTy->getScalarSizeInBits ();
7330
7329
7331
- // Following test does NOT adjust InputSize downwards for signed inputs,
7330
+ // Following test does NOT adjust IntWidth downwards for signed inputs,
7332
7331
// because the most negative value still requires all the mantissa bits
7333
7332
// to distinguish it from one less than that value.
7334
- if ((int )InputSize > MantissaWidth) {
7333
+ if ((int )IntWidth > MantissaWidth) {
7335
7334
// Conversion would lose accuracy. Check if loss can impact comparison.
7336
7335
int Exp = ilogb (RHS);
7337
7336
if (Exp == APFloat::IEK_Inf) {
7338
7337
int MaxExponent = ilogb (APFloat::getLargest (RHS.getSemantics ()));
7339
- if (MaxExponent < (int )InputSize - !LHSUnsigned)
7338
+ if (MaxExponent < (int )IntWidth - !LHSUnsigned)
7340
7339
// Conversion could create infinity.
7341
7340
return nullptr ;
7342
7341
} else {
7343
7342
// Note that if RHS is zero or NaN, then Exp is negative
7344
7343
// and first condition is trivially false.
7345
- if (MantissaWidth <= Exp && Exp <= (int )InputSize - !LHSUnsigned)
7344
+ if (MantissaWidth <= Exp && Exp <= (int )IntWidth - !LHSUnsigned)
7346
7345
// Conversion could affect comparison.
7347
7346
return nullptr ;
7348
7347
}
@@ -7390,8 +7389,6 @@ Instruction *InstCombinerImpl::foldFCmpIntToFPConst(FCmpInst &I,
7390
7389
7391
7390
// See if the FP constant is too large for the integer. For example,
7392
7391
// comparing an i8 to 300.0.
7393
- unsigned IntWidth = IntTy->getScalarSizeInBits ();
7394
-
7395
7392
if (!LHSUnsigned) {
7396
7393
// If the RHS value is > SignedMax, fold the comparison. This handles +INF
7397
7394
// and large values.
0 commit comments