llvm.org GIT mirror llvm / eaf0894
Enhance APFloat to retain bits of NaNs (fixes oggenc). Use APFloat interfaces for more references, mostly of ConstantFPSDNode. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41632 91177308-0d34-0410-b5e6-96231b3b80d8 Dale Johannesen 12 years ago
11 changed file(s) with 156 addition(s) and 114 deletion(s). Raw diff Collapse all Expand all
6363 so that the smallest denormal has just the least significant bit
6464 of the significand set. The sign of zeroes and infinities is
6565 significant; the exponent and significand of such numbers is
66 indeterminate and meaningless. For QNaNs the sign bit, as well as
67 the exponent and significand are indeterminate and meaningless.
66 not stored, but has a known implicit (deterministic) value:
67 0 for the significands, 0 for zero exponent, all 1 bits for
68 infinity exponent. For NaNs the sign and significand are
69 deterministic, although not really meaningful; the exponent is
70 implicitly all 1 bits.
6871
6972 TODO
7073 ====
154157 /* Category of internally-represented number. */
155158 enum fltCategory {
156159 fcInfinity,
157 fcQNaN,
160 fcNaN,
158161 fcNormal,
159162 fcZero
160163 };
191194 whatever it is you really mean. */
192195 // bool operator==(const APFloat &) const; // DO NOT IMPLEMENT
193196
194 /* IEEE comparison with another floating point number (QNaNs
197 /* IEEE comparison with another floating point number (NaNs
195198 compare unordered, 0==-0). */
196199 cmpResult compare(const APFloat &) const;
197200
204207 bool isZero() const { return category == fcZero; }
205208 bool isNonZero() const { return category != fcZero; }
206209 bool isNegative() const { return sign; }
210 bool isPosZero() const { return isZero() && !isNegative(); }
211 bool isNegZero() const { return isZero() && isNegative(); }
207212
208213 APFloat& operator=(const APFloat &);
209214
1414 #define LLVM_ADT_STRINGEXTRAS_H
1515
1616 #include "llvm/Support/DataTypes.h"
17 #include "llvm/ADT/APFloat.h"
1718 #include
1819 #include
1920 #include
9192 return B;
9293 }
9394
95 static inline std::string ftostr(APFloat V) {
96 if (&V.getSemantics() == &APFloat::IEEEsingle)
97 return ftostr(V.convertToDouble());
98 else if (&V.getSemantics() == &APFloat::IEEEdouble)
99 return ftostr((double)V.convertToFloat());
100 return 0; // error
101 }
102
94103 static inline std::string LowercaseString(const std::string &S) {
95104 std::string result(S);
96105 for (unsigned i = 0; i < S.length(); ++i)
108108 } else if (isa(NotZero)) {
109109 MVT::ValueType VT = NotZero.getValueType();
110110 if (VT== MVT::f64) {
111 if (DoubleToBits(cast(NotZero)->getValue()) !=
111 if (DoubleToBits(cast(NotZero)->
112 getValueAPF().convertToDouble()) !=
112113 (uint64_t)-1)
113114 return false;
114115 } else {
115 if (FloatToBits(cast(NotZero)->getValue()) !=
116 if (FloatToBits(cast(NotZero)->
117 getValueAPF().convertToFloat()) !=
116118 (uint32_t)-1)
117119 return false;
118120 }
154156 if (!cast(Zero)->isNullValue())
155157 return false;
156158 } else if (isa(Zero)) {
157 if (!cast(Zero)->isExactlyValue(0.0))
159 if (!cast(Zero)->getValueAPF().isPosZero())
158160 return false;
159161 } else
160162 return false;
319321 ID.AddInteger(cast(N)->getValue());
320322 break;
321323 case ISD::TargetConstantFP:
322 case ISD::ConstantFP:
323 ID.AddDouble(cast(N)->getValue());
324 break;
324 case ISD::ConstantFP: {
325 APFloat V = cast(N)->getValueAPF();
326 if (&V.getSemantics() == &APFloat::IEEEdouble)
327 ID.AddDouble(V.convertToDouble());
328 else if (&V.getSemantics() == &APFloat::IEEEsingle)
329 ID.AddDouble((double)V.convertToFloat());
330 else
331 assert(0);
332 break;
333 }
325334 case ISD::TargetGlobalAddress:
326335 case ISD::GlobalAddress:
327336 case ISD::TargetGlobalTLSAddress:
965974 }
966975 if (ConstantFPSDNode *N1C = dyn_cast(N1.Val))
967976 if (ConstantFPSDNode *N2C = dyn_cast(N2.Val)) {
968 double C1 = N1C->getValue(), C2 = N2C->getValue();
969
977
978 APFloat::cmpResult R = N1C->getValueAPF().compare(N2C->getValueAPF());
970979 switch (Cond) {
971 default: break; // FIXME: Implement the rest of these!
972 case ISD::SETEQ: return getConstant(C1 == C2, VT);
973 case ISD::SETNE: return getConstant(C1 != C2, VT);
974 case ISD::SETLT: return getConstant(C1 < C2, VT);
975 case ISD::SETGT: return getConstant(C1 > C2, VT);
976 case ISD::SETLE: return getConstant(C1 <= C2, VT);
977 case ISD::SETGE: return getConstant(C1 >= C2, VT);
980 default: break;
981 case ISD::SETOEQ:
982 case ISD::SETEQ: return getConstant(R==APFloat::cmpEqual, VT);
983 case ISD::SETONE:
984 case ISD::SETNE: return getConstant(R==APFloat::cmpGreaterThan ||
985 R==APFloat::cmpLessThan, VT);
986 case ISD::SETOLT:
987 case ISD::SETLT: return getConstant(R==APFloat::cmpLessThan, VT);
988 case ISD::SETOGT:
989 case ISD::SETGT: return getConstant(R==APFloat::cmpGreaterThan, VT);
990 case ISD::SETOLE:
991 case ISD::SETLE: return getConstant(R==APFloat::cmpLessThan ||
992 R==APFloat::cmpEqual, VT);
993 case ISD::SETOGE:
994 case ISD::SETGE: return getConstant(R==APFloat::cmpGreaterThan ||
995 R==APFloat::cmpEqual, VT);
996 case ISD::SETO: return getConstant(R!=APFloat::cmpUnordered, VT);
997 case ISD::SETUO: return getConstant(R==APFloat::cmpUnordered, VT);
998 case ISD::SETUEQ: return getConstant(R==APFloat::cmpUnordered ||
999 R==APFloat::cmpEqual, VT);
1000 case ISD::SETUNE: return getConstant(R!=APFloat::cmpEqual, VT);
1001 case ISD::SETULT: return getConstant(R==APFloat::cmpUnordered ||
1002 R==APFloat::cmpLessThan, VT);
1003 case ISD::SETUGT: return getConstant(R==APFloat::cmpGreaterThan ||
1004 R==APFloat::cmpUnordered, VT);
1005 case ISD::SETULE: return getConstant(R!=APFloat::cmpGreaterThan, VT);
1006 case ISD::SETUGE: return getConstant(R!=APFloat::cmpLessThan, VT);
9781007 }
9791008 } else {
9801009 // Ensure that the constant occurs on the RHS.
9494 if (const ConstantSDNode *CSDN = dyn_cast(Node)) {
9595 Op += ": " + utostr(CSDN->getValue());
9696 } else if (const ConstantFPSDNode *CSDN = dyn_cast(Node)) {
97 Op += ": " + ftostr(CSDN->getValue());
97 Op += ": " + ftostr(CSDN->getValueAPF());
9898 } else if (const GlobalAddressSDNode *GADN =
9999 dyn_cast(Node)) {
100100 int offset = GADN->getOffset();
114114 Op += "<" + SS.str() + ">";
115115 } else {
116116 if (ConstantFP *CFP = dyn_cast(CP->getConstVal()))
117 Op += "<" + ftostr(CFP->getValue()) + ">";
117 Op += "<" + ftostr(CFP->getValueAPF()) + ">";
118118 else if (ConstantInt *CI = dyn_cast(CP->getConstVal()))
119119 Op += "<" + utostr(CI->getZExtValue()) + ">";
120120 else {
246246 sign = rhs.sign;
247247 category = rhs.category;
248248 exponent = rhs.exponent;
249 if(category == fcNormal)
249 if(category == fcNormal || category == fcNaN)
250250 copySignificand(rhs);
251251 }
252252
253253 void
254254 APFloat::copySignificand(const APFloat &rhs)
255255 {
256 assert(category == fcNormal);
256 assert(category == fcNormal || category == fcNaN);
257257 assert(rhs.partCount() >= partCount());
258258
259259 APInt::tcAssign(significandParts(), rhs.significandParts(),
279279 if (this == &rhs)
280280 return true;
281281 if (semantics != rhs.semantics ||
282 category != rhs.category)
282 category != rhs.category ||
283 sign != rhs.sign)
283284 return false;
284 if (category==fcQNaN)
285 if (category==fcZero || category==fcInfinity)
285286 return true;
286 else if (category==fcZero || category==fcInfinity)
287 return sign==rhs.sign;
287 else if (category==fcNormal && exponent!=rhs.exponent)
288 return false;
288289 else {
289 if (sign!=rhs.sign || exponent!=rhs.exponent)
290 return false;
291290 int i= partCount();
292291 const integerPart* p=significandParts();
293292 const integerPart* q=rhs.significandParts();
357356 integerPart *
358357 APFloat::significandParts()
359358 {
360 assert(category == fcNormal);
359 assert(category == fcNormal || category == fcNaN);
361360
362361 if(partCount() > 1)
363362 return significand.parts;
700699 APFloat::roundAwayFromZero(roundingMode rounding_mode,
701700 lostFraction lost_fraction)
702701 {
703 /* QNaNs and infinities should not have lost fractions. */
702 /* NaNs and infinities should not have lost fractions. */
704703 assert(category == fcNormal || category == fcZero);
705704
706705 /* Our caller has already handled this case. */
850849 default:
851850 assert(0);
852851
853 case convolve(fcQNaN, fcZero):
854 case convolve(fcQNaN, fcNormal):
855 case convolve(fcQNaN, fcInfinity):
856 case convolve(fcQNaN, fcQNaN):
852 case convolve(fcNaN, fcZero):
853 case convolve(fcNaN, fcNormal):
854 case convolve(fcNaN, fcInfinity):
855 case convolve(fcNaN, fcNaN):
857856 case convolve(fcNormal, fcZero):
858857 case convolve(fcInfinity, fcNormal):
859858 case convolve(fcInfinity, fcZero):
860859 return opOK;
861860
862 case convolve(fcZero, fcQNaN):
863 case convolve(fcNormal, fcQNaN):
864 case convolve(fcInfinity, fcQNaN):
865 category = fcQNaN;
861 case convolve(fcZero, fcNaN):
862 case convolve(fcNormal, fcNaN):
863 case convolve(fcInfinity, fcNaN):
864 category = fcNaN;
865 copySignificand(rhs);
866866 return opOK;
867867
868868 case convolve(fcNormal, fcInfinity):
884884 /* Differently signed infinities can only be validly
885885 subtracted. */
886886 if(sign ^ rhs.sign != subtract) {
887 category = fcQNaN;
887 category = fcNaN;
888 // Arbitrary but deterministic value for significand
889 APInt::tcSet(significandParts(), ~0U, partCount());
888890 return opInvalidOp;
889891 }
890892
973975 default:
974976 assert(0);
975977
976 case convolve(fcQNaN, fcZero):
977 case convolve(fcQNaN, fcNormal):
978 case convolve(fcQNaN, fcInfinity):
979 case convolve(fcQNaN, fcQNaN):
980 case convolve(fcZero, fcQNaN):
981 case convolve(fcNormal, fcQNaN):
982 case convolve(fcInfinity, fcQNaN):
983 category = fcQNaN;
978 case convolve(fcNaN, fcZero):
979 case convolve(fcNaN, fcNormal):
980 case convolve(fcNaN, fcInfinity):
981 case convolve(fcNaN, fcNaN):
982 return opOK;
983
984 case convolve(fcZero, fcNaN):
985 case convolve(fcNormal, fcNaN):
986 case convolve(fcInfinity, fcNaN):
987 category = fcNaN;
988 copySignificand(rhs);
984989 return opOK;
985990
986991 case convolve(fcNormal, fcInfinity):
9971002
9981003 case convolve(fcZero, fcInfinity):
9991004 case convolve(fcInfinity, fcZero):
1000 category = fcQNaN;
1005 category = fcNaN;
1006 // Arbitrary but deterministic value for significand
1007 APInt::tcSet(significandParts(), ~0U, partCount());
10011008 return opInvalidOp;
10021009
10031010 case convolve(fcNormal, fcNormal):
10121019 default:
10131020 assert(0);
10141021
1015 case convolve(fcQNaN, fcZero):
1016 case convolve(fcQNaN, fcNormal):
1017 case convolve(fcQNaN, fcInfinity):
1018 case convolve(fcQNaN, fcQNaN):
1022 case convolve(fcNaN, fcZero):
1023 case convolve(fcNaN, fcNormal):
1024 case convolve(fcNaN, fcInfinity):
1025 case convolve(fcNaN, fcNaN):
10191026 case convolve(fcInfinity, fcZero):
10201027 case convolve(fcInfinity, fcNormal):
10211028 case convolve(fcZero, fcInfinity):
10221029 case convolve(fcZero, fcNormal):
10231030 return opOK;
10241031
1025 case convolve(fcZero, fcQNaN):
1026 case convolve(fcNormal, fcQNaN):
1027 case convolve(fcInfinity, fcQNaN):
1028 category = fcQNaN;
1032 case convolve(fcZero, fcNaN):
1033 case convolve(fcNormal, fcNaN):
1034 case convolve(fcInfinity, fcNaN):
1035 category = fcNaN;
1036 copySignificand(rhs);
10291037 return opOK;
10301038
10311039 case convolve(fcNormal, fcInfinity):
10381046
10391047 case convolve(fcInfinity, fcInfinity):
10401048 case convolve(fcZero, fcZero):
1041 category = fcQNaN;
1049 category = fcNaN;
1050 // Arbitrary but deterministic value for significand
1051 APInt::tcSet(significandParts(), ~0U, partCount());
10421052 return opInvalidOp;
10431053
10441054 case convolve(fcNormal, fcNormal):
11711181 /* FS can only be opOK or opInvalidOp. There is no more work
11721182 to do in the latter case. The IEEE-754R standard says it is
11731183 implementation-defined in this case whether, if ADDEND is a
1174 quiet QNaN, we raise invalid op; this implementation does so.
1184 quiet NaN, we raise invalid op; this implementation does so.
11751185
11761186 If we need to do the addition we can do so with normal
11771187 precision. */
11941204 default:
11951205 assert(0);
11961206
1197 case convolve(fcQNaN, fcZero):
1198 case convolve(fcQNaN, fcNormal):
1199 case convolve(fcQNaN, fcInfinity):
1200 case convolve(fcQNaN, fcQNaN):
1201 case convolve(fcZero, fcQNaN):
1202 case convolve(fcNormal, fcQNaN):
1203 case convolve(fcInfinity, fcQNaN):
1207 case convolve(fcNaN, fcZero):
1208 case convolve(fcNaN, fcNormal):
1209 case convolve(fcNaN, fcInfinity):
1210 case convolve(fcNaN, fcNaN):
1211 case convolve(fcZero, fcNaN):
1212 case convolve(fcNormal, fcNaN):
1213 case convolve(fcInfinity, fcNaN):
12041214 return cmpUnordered;
12051215
12061216 case convolve(fcInfinity, fcNormal):
13081318 int bits;
13091319
13101320 /* Handle the three special cases first. */
1311 if(category == fcInfinity || category == fcQNaN)
1321 if(category == fcInfinity || category == fcNaN)
13121322 return opInvalidOp;
13131323
13141324 partsCount = partCountForBits(width);
15161526 APFloat::getHashValue() const {
15171527 if (category==fcZero) return sign<<8 | semantics->precision ;
15181528 else if (category==fcInfinity) return sign<<9 | semantics->precision;
1519 else if (category==fcQNaN) return 1<<10 | semantics->precision;
1529 else if (category==fcNaN) return 1<<10 | semantics->precision;
15201530 else {
15211531 uint32_t hash = sign<<11 | semantics->precision | exponent<<12;
15221532 const integerPart* p = significandParts();
15371547 assert(semantics == (const llvm::fltSemantics* const)&IEEEdouble);
15381548 assert (partCount()==1);
15391549
1540 uint64_t myexponent, mysign, mysignificand;
1550 uint64_t myexponent, mysignificand;
15411551
15421552 if (category==fcNormal) {
1543 mysign = sign;
15441553 mysignificand = *significandParts();
15451554 myexponent = exponent+1023; //bias
15461555 } else if (category==fcZero) {
1547 mysign = sign;
15481556 myexponent = 0;
15491557 mysignificand = 0;
15501558 } else if (category==fcInfinity) {
1551 mysign = sign;
15521559 myexponent = 0x7ff;
15531560 mysignificand = 0;
1554 } else if (category==fcQNaN) {
1555 mysign = 0;
1561 } else if (category==fcNaN) {
15561562 myexponent = 0x7ff;
1557 mysignificand = 0xfffffffffffffLL;
1563 mysignificand = *significandParts();
15581564 } else
15591565 assert(0);
15601566
1561 return BitsToDouble(((mysign & 1) << 63) | ((myexponent & 0x7ff) << 52) |
1567 return BitsToDouble((((uint64_t)sign & 1) << 63) |
1568 ((myexponent & 0x7ff) << 52) |
15621569 (mysignificand & 0xfffffffffffffLL));
15631570 }
15641571
15671574 assert(semantics == (const llvm::fltSemantics* const)&IEEEsingle);
15681575 assert (partCount()==1);
15691576
1570 uint32_t mysign, myexponent, mysignificand;
1577 uint32_t myexponent, mysignificand;
15711578
15721579 if (category==fcNormal) {
1573 mysign = sign;
15741580 myexponent = exponent+127; //bias
15751581 mysignificand = *significandParts();
15761582 } else if (category==fcZero) {
1577 mysign = sign;
15781583 myexponent = 0;
15791584 mysignificand = 0;
15801585 } else if (category==fcInfinity) {
1581 mysign = sign;
15821586 myexponent = 0xff;
15831587 mysignificand = 0;
1584 } else if (category==fcQNaN) {
1585 mysign = sign;
1588 } else if (category==fcNaN) {
15861589 myexponent = 0x7ff;
1587 mysignificand = 0x7fffff;
1590 mysignificand = *significandParts();
15881591 } else
15891592 assert(0);
15901593
1591 return BitsToFloat(((mysign&1) << 31) | ((myexponent&0xff) << 23) |
1594 return BitsToFloat(((sign&1) << 31) | ((myexponent&0xff) << 23) |
15921595 (mysignificand & 0x7fffff));
15931596 }
15941597
15951598 APFloat::APFloat(double d) {
15961599 uint64_t i = DoubleToBits(d);
1597 uint64_t mysign = i >> 63;
15981600 uint64_t myexponent = (i >> 52) & 0x7ff;
15991601 uint64_t mysignificand = i & 0xfffffffffffffLL;
16001602
16011603 initialize(&APFloat::IEEEdouble);
16021604 assert(partCount()==1);
16031605
1606 sign = i>>63;
16041607 if (myexponent==0 && mysignificand==0) {
16051608 // exponent, significand meaningless
16061609 category = fcZero;
1607 sign = mysign;
16081610 } else if (myexponent==0x7ff && mysignificand==0) {
16091611 // exponent, significand meaningless
16101612 category = fcInfinity;
1611 sign = mysign;
1612 } else if (myexponent==0x7ff && (mysignificand & 0x8000000000000LL)) {
1613 // sign, exponent, significand meaningless
1614 category = fcQNaN;
1613 } else if (myexponent==0x7ff && mysignificand!=0) {
1614 // exponent meaningless
1615 category = fcNaN;
1616 *significandParts() = mysignificand;
16151617 } else {
1616 sign = mysign;
16171618 category = fcNormal;
16181619 exponent = myexponent - 1023;
1619 *significandParts() = mysignificand | 0x10000000000000LL;
1620 }
1620 *significandParts() = mysignificand | 0x10000000000000LL;
1621 }
16211622 }
16221623
16231624 APFloat::APFloat(float f) {
16241625 uint32_t i = FloatToBits(f);
1625 uint32_t mysign = i >> 31;
16261626 uint32_t myexponent = (i >> 23) & 0xff;
16271627 uint32_t mysignificand = i & 0x7fffff;
16281628
16291629 initialize(&APFloat::IEEEsingle);
16301630 assert(partCount()==1);
16311631
1632 sign = i >> 31;
16321633 if (myexponent==0 && mysignificand==0) {
16331634 // exponent, significand meaningless
16341635 category = fcZero;
1635 sign = mysign;
16361636 } else if (myexponent==0xff && mysignificand==0) {
16371637 // exponent, significand meaningless
16381638 category = fcInfinity;
1639 sign = mysign;
16401639 } else if (myexponent==0xff && (mysignificand & 0x400000)) {
16411640 // sign, exponent, significand meaningless
1642 category = fcQNaN;
1641 category = fcNaN;
1642 *significandParts() = mysignificand;
16431643 } else {
16441644 category = fcNormal;
1645 sign = mysign;
16461645 exponent = myexponent - 127; //bias
16471646 *significandParts() = mysignificand | 0x800000; // integer bit
16481647 }
10321032 /// isFloatingPointZero - Return true if this is +0.0.
10331033 static bool isFloatingPointZero(SDOperand Op) {
10341034 if (ConstantFPSDNode *CFP = dyn_cast(Op))
1035 return CFP->isExactlyValue(0.0);
1035 return CFP->getValueAPF().isPosZero();
10361036 else if (ISD::isEXTLoad(Op.Val) || ISD::isNON_EXTLoad(Op.Val)) {
10371037 // Maybe this has already been legalized into the constant pool?
10381038 if (Op.getOperand(1).getOpcode() == ARMISD::Wrapper) {
10391039 SDOperand WrapperOp = Op.getOperand(1).getOperand(0);
10401040 if (ConstantPoolSDNode *CP = dyn_cast(WrapperOp))
10411041 if (ConstantFP *CFP = dyn_cast(CP->getConstVal()))
1042 return CFP->isExactlyValue(0.0);
1042 return CFP->getValueAPF().isPosZero();
10431043 }
10441044 }
10451045 return false;
130130
131131 static bool isFPZ(SDOperand N) {
132132 ConstantFPSDNode *CN = dyn_cast(N);
133 return (CN && (CN->isExactlyValue(+0.0) || CN->isExactlyValue(-0.0)));
133 return (CN && (CN->getValueAPF().isZero()));
134134 }
135135 static bool isFPZn(SDOperand N) {
136136 ConstantFPSDNode *CN = dyn_cast(N);
137 return (CN && CN->isExactlyValue(-0.0));
137 return (CN && CN->getValueAPF().isNegZero());
138138 }
139139 static bool isFPZp(SDOperand N) {
140140 ConstantFPSDNode *CN = dyn_cast(N);
141 return (CN && CN->isExactlyValue(+0.0));
141 return (CN && CN->getValueAPF().isPosZero());
142142 }
143143
144144 public:
333333 ConstantFPSDNode *CN = cast(N);
334334 bool isDouble = N->getValueType(0) == MVT::f64;
335335 MVT::ValueType T = isDouble ? MVT::f64 : MVT::f32;
336 if (CN->isExactlyValue(+0.0)) {
336 if (CN->getValueAPF().isPosZero()) {
337337 return CurDAG->SelectNodeTo(N, isDouble ? Alpha::CPYST : Alpha::CPYSS,
338338 T, CurDAG->getRegister(Alpha::F31, T),
339339 CurDAG->getRegister(Alpha::F31, T));
340 } else if ( CN->isExactlyValue(-0.0)) {
340 } else if (CN->getValueAPF().isNegZero()) {
341341 return CurDAG->SelectNodeTo(N, isDouble ? Alpha::CPYSNT : Alpha::CPYSNS,
342342 T, CurDAG->getRegister(Alpha::F31, T),
343343 CurDAG->getRegister(Alpha::F31, T));
403403 SDOperand Chain = CurDAG->getEntryNode(); // this is a constant, so..
404404
405405 SDOperand V;
406 if (cast(N)->isExactlyValue(+0.0)) {
406 if (cast(N)->getValueAPF().isPosZero()) {
407407 V = CurDAG->getCopyFromReg(Chain, IA64::F0, MVT::f64);
408 } else if (cast(N)->isExactlyValue(+1.0)) {
408 } else if (cast(N)->isExactlyValue(APFloat(+1.0))) {
409409 V = CurDAG->getCopyFromReg(Chain, IA64::F1, MVT::f64);
410410 } else
411411 assert(0 && "Unexpected FP constant!");
361361 /// isFloatingPointZero - Return true if this is 0.0 or -0.0.
362362 static bool isFloatingPointZero(SDOperand Op) {
363363 if (ConstantFPSDNode *CFP = dyn_cast(Op))
364 return CFP->isExactlyValue(-0.0) || CFP->isExactlyValue(0.0);
364 return CFP->getValueAPF().isZero();
365365 else if (ISD::isEXTLoad(Op.Val) || ISD::isNON_EXTLoad(Op.Val)) {
366366 // Maybe this has already been legalized into the constant pool?
367367 if (ConstantPoolSDNode *CP = dyn_cast(Op.getOperand(1)))
368368 if (ConstantFP *CFP = dyn_cast(CP->getConstVal()))
369 return CFP->isExactlyValue(-0.0) || CFP->isExactlyValue(0.0);
369 return CFP->getValueAPF().isZero();
370370 }
371371 return false;
372372 }
529529 assert(N->getOpcode() == ISD::BUILD_VECTOR);
530530 if (PPC::isSplatShuffleMask(N, N->getNumOperands()))
531531 if (ConstantFPSDNode *CFP = dyn_cast(N))
532 return CFP->isExactlyValue(-0.0);
532 return CFP->getValueAPF().isNegZero();
533533 return false;
534534 }
535535
621621 ValSizeInBytes = MVT::getSizeInBits(CN->getValueType(0))/8;
622622 } else if (ConstantFPSDNode *CN = dyn_cast(OpVal)) {
623623 assert(CN->getValueType(0) == MVT::f32 && "Only one legal FP vector type!");
624 Value = FloatToBits(CN->getValue());
624 Value = FloatToBits(CN->getValueAPF().convertToFloat());
625625 ValSizeInBytes = 4;
626626 }
627627
21932193 } else if (ConstantFPSDNode *CN = dyn_cast(OpVal)) {
21942194 assert(CN->getValueType(0) == MVT::f32 &&
21952195 "Only one legal FP vector type!");
2196 EltBits = FloatToBits(CN->getValue());
2196 EltBits = FloatToBits(CN->getValueAPF().convertToFloat());
21972197 } else {
21982198 // Nonconstant element.
21992199 return true;
816816 return ((isa(Elt) &&
817817 cast(Elt)->getValue() == 0) ||
818818 (isa(Elt) &&
819 cast(Elt)->isExactlyValue(0.0)));
819 cast(Elt)->getValueAPF().isPosZero()));
820820 }
821821
822822
23022302 return ((isa(Elt) &&
23032303 cast(Elt)->getValue() == 0) ||
23042304 (isa(Elt) &&
2305 cast(Elt)->isExactlyValue(0.0)));
2305 cast(Elt)->getValueAPF().isPosZero()));
23062306 }
23072307
23082308 /// isZeroShuffle - Returns true if N is a VECTOR_SHUFFLE that can be resolved