mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-19 13:38:56 +00:00
Don't rely on doubles comparing identical to each other, which doesn't work
for 0.0 and -0.0. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20230 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b29cb29364
commit
d8658616cf
@ -196,10 +196,15 @@ void SelectionDAG::DeleteNodeIfDead(SDNode *N, void *NodeSet) {
|
|||||||
Constants.erase(std::make_pair(cast<ConstantSDNode>(N)->getValue(),
|
Constants.erase(std::make_pair(cast<ConstantSDNode>(N)->getValue(),
|
||||||
N->getValueType(0)));
|
N->getValueType(0)));
|
||||||
break;
|
break;
|
||||||
case ISD::ConstantFP:
|
case ISD::ConstantFP: {
|
||||||
ConstantFPs.erase(std::make_pair(cast<ConstantFPSDNode>(N)->getValue(),
|
union {
|
||||||
N->getValueType(0)));
|
double DV;
|
||||||
|
uint64_t IV;
|
||||||
|
};
|
||||||
|
DV = cast<ConstantFPSDNode>(N)->getValue();
|
||||||
|
ConstantFPs.erase(std::make_pair(IV, N->getValueType(0)));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case ISD::GlobalAddress:
|
case ISD::GlobalAddress:
|
||||||
GlobalValues.erase(cast<GlobalAddressSDNode>(N)->getGlobal());
|
GlobalValues.erase(cast<GlobalAddressSDNode>(N)->getGlobal());
|
||||||
break;
|
break;
|
||||||
@ -299,7 +304,17 @@ SDOperand SelectionDAG::getConstantFP(double Val, MVT::ValueType VT) {
|
|||||||
if (VT == MVT::f32)
|
if (VT == MVT::f32)
|
||||||
Val = (float)Val; // Mask out extra precision.
|
Val = (float)Val; // Mask out extra precision.
|
||||||
|
|
||||||
SDNode *&N = ConstantFPs[std::make_pair(Val, VT)];
|
// Do the map lookup using the actual bit pattern for the floating point
|
||||||
|
// value, so that we don't have problems with 0.0 comparing equal to -0.0, and
|
||||||
|
// we don't have issues with SNANs.
|
||||||
|
union {
|
||||||
|
double DV;
|
||||||
|
uint64_t IV;
|
||||||
|
};
|
||||||
|
|
||||||
|
DV = Val;
|
||||||
|
|
||||||
|
SDNode *&N = ConstantFPs[std::make_pair(IV, VT)];
|
||||||
if (N) return SDOperand(N, 0);
|
if (N) return SDOperand(N, 0);
|
||||||
N = new ConstantFPSDNode(Val, VT);
|
N = new ConstantFPSDNode(Val, VT);
|
||||||
AllNodes.push_back(N);
|
AllNodes.push_back(N);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user