forked from OSchip/llvm-project
[APFloat] Converted all references to APFloat::isNormal => APFloat::isFiniteNonZero.
Turns out all the references were in llvm and not in clang. llvm-svn: 184356
This commit is contained in:
parent
38e6b86da0
commit
3cb77ab98a
|
@ -362,7 +362,7 @@ public:
|
||||||
///
|
///
|
||||||
/// The current implementation of isNormal() differs from this by treating
|
/// The current implementation of isNormal() differs from this by treating
|
||||||
/// subnormal values as normal values.
|
/// subnormal values as normal values.
|
||||||
bool isIEEENormal() const { return !isDenormal() && isNormal(); }
|
bool isIEEENormal() const { return !isDenormal() && isFiniteNonZero(); }
|
||||||
|
|
||||||
/// Returns true if and only if the current value is zero, subnormal, or
|
/// Returns true if and only if the current value is zero, subnormal, or
|
||||||
/// normal.
|
/// normal.
|
||||||
|
|
|
@ -1955,7 +1955,7 @@ void Verifier::visitInstruction(Instruction &I) {
|
||||||
Value *Op0 = MD->getOperand(0);
|
Value *Op0 = MD->getOperand(0);
|
||||||
if (ConstantFP *CFP0 = dyn_cast_or_null<ConstantFP>(Op0)) {
|
if (ConstantFP *CFP0 = dyn_cast_or_null<ConstantFP>(Op0)) {
|
||||||
APFloat Accuracy = CFP0->getValueAPF();
|
APFloat Accuracy = CFP0->getValueAPF();
|
||||||
Assert1(Accuracy.isNormal() && !Accuracy.isNegative(),
|
Assert1(Accuracy.isFiniteNonZero() && !Accuracy.isNegative(),
|
||||||
"fpmath accuracy not a positive number!", &I);
|
"fpmath accuracy not a positive number!", &I);
|
||||||
} else {
|
} else {
|
||||||
Assert1(false, "invalid fpmath accuracy!", &I);
|
Assert1(false, "invalid fpmath accuracy!", &I);
|
||||||
|
|
|
@ -679,7 +679,7 @@ APFloat::operator=(const APFloat &rhs)
|
||||||
|
|
||||||
bool
|
bool
|
||||||
APFloat::isDenormal() const {
|
APFloat::isDenormal() const {
|
||||||
return isNormal() && (exponent == semantics->minExponent) &&
|
return isFiniteNonZero() && (exponent == semantics->minExponent) &&
|
||||||
(APInt::tcExtractBit(significandParts(),
|
(APInt::tcExtractBit(significandParts(),
|
||||||
semantics->precision - 1) == 0);
|
semantics->precision - 1) == 0);
|
||||||
}
|
}
|
||||||
|
@ -689,7 +689,7 @@ APFloat::isSmallest() const {
|
||||||
// The smallest number by magnitude in our format will be the smallest
|
// The smallest number by magnitude in our format will be the smallest
|
||||||
// denormal, i.e. the floating point number with exponent being minimum
|
// denormal, i.e. the floating point number with exponent being minimum
|
||||||
// exponent and significand bitwise equal to 1 (i.e. with MSB equal to 0).
|
// exponent and significand bitwise equal to 1 (i.e. with MSB equal to 0).
|
||||||
return isNormal() && exponent == semantics->minExponent &&
|
return isFiniteNonZero() && exponent == semantics->minExponent &&
|
||||||
significandMSB() == 0;
|
significandMSB() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -741,7 +741,7 @@ bool
|
||||||
APFloat::isLargest() const {
|
APFloat::isLargest() const {
|
||||||
// The largest number by magnitude in our format will be the floating point
|
// The largest number by magnitude in our format will be the floating point
|
||||||
// number with maximum exponent and with significand that is all ones.
|
// number with maximum exponent and with significand that is all ones.
|
||||||
return isNormal() && exponent == semantics->maxExponent
|
return isFiniteNonZero() && exponent == semantics->maxExponent
|
||||||
&& isSignificandAllOnes();
|
&& isSignificandAllOnes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -488,7 +488,7 @@ Value *FAddCombine::performFactorization(Instruction *I) {
|
||||||
createFSub(AddSub0, AddSub1);
|
createFSub(AddSub0, AddSub1);
|
||||||
if (ConstantFP *CFP = dyn_cast<ConstantFP>(NewAddSub)) {
|
if (ConstantFP *CFP = dyn_cast<ConstantFP>(NewAddSub)) {
|
||||||
const APFloat &F = CFP->getValueAPF();
|
const APFloat &F = CFP->getValueAPF();
|
||||||
if (!F.isNormal() || F.isDenormal())
|
if (!F.isFiniteNonZero() || F.isDenormal())
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -338,13 +338,13 @@ static bool isFMulOrFDivWithConstant(Value *V) {
|
||||||
if (C0 && C1)
|
if (C0 && C1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return (C0 && C0->getValueAPF().isNormal()) ||
|
return (C0 && C0->getValueAPF().isFiniteNonZero()) ||
|
||||||
(C1 && C1->getValueAPF().isNormal());
|
(C1 && C1->getValueAPF().isFiniteNonZero());
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isNormalFp(const ConstantFP *C) {
|
static bool isNormalFp(const ConstantFP *C) {
|
||||||
const APFloat &Flt = C->getValueAPF();
|
const APFloat &Flt = C->getValueAPF();
|
||||||
return Flt.isNormal() && !Flt.isDenormal();
|
return Flt.isFiniteNonZero() && !Flt.isDenormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// foldFMulConst() is a helper routine of InstCombiner::visitFMul().
|
/// foldFMulConst() is a helper routine of InstCombiner::visitFMul().
|
||||||
|
@ -423,7 +423,7 @@ Instruction *InstCombiner::visitFMul(BinaryOperator &I) {
|
||||||
return NV;
|
return NV;
|
||||||
|
|
||||||
ConstantFP *C = dyn_cast<ConstantFP>(Op1);
|
ConstantFP *C = dyn_cast<ConstantFP>(Op1);
|
||||||
if (C && AllowReassociate && C->getValueAPF().isNormal()) {
|
if (C && AllowReassociate && C->getValueAPF().isFiniteNonZero()) {
|
||||||
// Let MDC denote an expression in one of these forms:
|
// Let MDC denote an expression in one of these forms:
|
||||||
// X * C, C/X, X/C, where C is a constant.
|
// X * C, C/X, X/C, where C is a constant.
|
||||||
//
|
//
|
||||||
|
@ -450,7 +450,7 @@ Instruction *InstCombiner::visitFMul(BinaryOperator &I) {
|
||||||
Swap = true;
|
Swap = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (C1 && C1->getValueAPF().isNormal() &&
|
if (C1 && C1->getValueAPF().isFiniteNonZero() &&
|
||||||
isFMulOrFDivWithConstant(Opnd0)) {
|
isFMulOrFDivWithConstant(Opnd0)) {
|
||||||
Value *M1 = ConstantExpr::getFMul(C1, C);
|
Value *M1 = ConstantExpr::getFMul(C1, C);
|
||||||
Value *M0 = isNormalFp(cast<ConstantFP>(M1)) ?
|
Value *M0 = isNormalFp(cast<ConstantFP>(M1)) ?
|
||||||
|
@ -858,7 +858,7 @@ static Instruction *CvtFDivConstToReciprocal(Value *Dividend,
|
||||||
APFloat Reciprocal(FpVal.getSemantics());
|
APFloat Reciprocal(FpVal.getSemantics());
|
||||||
bool Cvt = FpVal.getExactInverse(&Reciprocal);
|
bool Cvt = FpVal.getExactInverse(&Reciprocal);
|
||||||
|
|
||||||
if (!Cvt && AllowReciprocal && FpVal.isNormal()) {
|
if (!Cvt && AllowReciprocal && FpVal.isFiniteNonZero()) {
|
||||||
Reciprocal = APFloat(FpVal.getSemantics(), 1.0f);
|
Reciprocal = APFloat(FpVal.getSemantics(), 1.0f);
|
||||||
(void)Reciprocal.divide(FpVal, APFloat::rmNearestTiesToEven);
|
(void)Reciprocal.divide(FpVal, APFloat::rmNearestTiesToEven);
|
||||||
Cvt = !Reciprocal.isDenormal();
|
Cvt = !Reciprocal.isDenormal();
|
||||||
|
@ -893,14 +893,14 @@ Instruction *InstCombiner::visitFDiv(BinaryOperator &I) {
|
||||||
//
|
//
|
||||||
Constant *C = ConstantExpr::getFDiv(C1, C2);
|
Constant *C = ConstantExpr::getFDiv(C1, C2);
|
||||||
const APFloat &F = cast<ConstantFP>(C)->getValueAPF();
|
const APFloat &F = cast<ConstantFP>(C)->getValueAPF();
|
||||||
if (F.isNormal() && !F.isDenormal())
|
if (F.isFiniteNonZero() && !F.isDenormal())
|
||||||
Res = BinaryOperator::CreateFMul(X, C);
|
Res = BinaryOperator::CreateFMul(X, C);
|
||||||
} else if (match(Op0, m_FDiv(m_Value(X), m_ConstantFP(C1)))) {
|
} else if (match(Op0, m_FDiv(m_Value(X), m_ConstantFP(C1)))) {
|
||||||
// (X/C1)/C2 => X /(C2*C1) [=> X * 1/(C2*C1) if reciprocal is allowed]
|
// (X/C1)/C2 => X /(C2*C1) [=> X * 1/(C2*C1) if reciprocal is allowed]
|
||||||
//
|
//
|
||||||
Constant *C = ConstantExpr::getFMul(C1, C2);
|
Constant *C = ConstantExpr::getFMul(C1, C2);
|
||||||
const APFloat &F = cast<ConstantFP>(C)->getValueAPF();
|
const APFloat &F = cast<ConstantFP>(C)->getValueAPF();
|
||||||
if (F.isNormal() && !F.isDenormal()) {
|
if (F.isFiniteNonZero() && !F.isDenormal()) {
|
||||||
Res = CvtFDivConstToReciprocal(X, cast<ConstantFP>(C),
|
Res = CvtFDivConstToReciprocal(X, cast<ConstantFP>(C),
|
||||||
AllowReciprocal);
|
AllowReciprocal);
|
||||||
if (!Res)
|
if (!Res)
|
||||||
|
@ -941,7 +941,7 @@ Instruction *InstCombiner::visitFDiv(BinaryOperator &I) {
|
||||||
|
|
||||||
if (Fold) {
|
if (Fold) {
|
||||||
const APFloat &FoldC = cast<ConstantFP>(Fold)->getValueAPF();
|
const APFloat &FoldC = cast<ConstantFP>(Fold)->getValueAPF();
|
||||||
if (FoldC.isNormal() && !FoldC.isDenormal()) {
|
if (FoldC.isFiniteNonZero() && !FoldC.isDenormal()) {
|
||||||
Instruction *R = CreateDiv ?
|
Instruction *R = CreateDiv ?
|
||||||
BinaryOperator::CreateFDiv(Fold, X) :
|
BinaryOperator::CreateFDiv(Fold, X) :
|
||||||
BinaryOperator::CreateFMul(X, Fold);
|
BinaryOperator::CreateFMul(X, Fold);
|
||||||
|
|
Loading…
Reference in New Issue