Make sure to auto-cse nullary ops

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23224 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2005-09-02 19:36:17 +00:00
parent ab2eb66f07
commit 70b9b1098a

View File

@ -326,7 +326,10 @@ void SelectionDAG::RemoveNodeFromCSEMaps(SDNode *N) {
break; break;
default: default:
if (N->getNumValues() == 1) { if (N->getNumValues() == 1) {
if (N->getNumOperands() == 1) { if (N->getNumOperands() == 0) {
Erased = NullaryOps.erase(std::make_pair(N->getOpcode(),
N->getValueType(0)));
} else if (N->getNumOperands() == 1) {
Erased = Erased =
UnaryOps.erase(std::make_pair(N->getOpcode(), UnaryOps.erase(std::make_pair(N->getOpcode(),
std::make_pair(N->getOperand(0), std::make_pair(N->getOperand(0),
@ -1010,8 +1013,11 @@ SDOperand SelectionDAG::SimplifySelectCC(SDOperand N1, SDOperand N2,
/// getNode - Gets or creates the specified node. /// getNode - Gets or creates the specified node.
/// ///
SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT) { SDOperand SelectionDAG::getNode(unsigned Opcode, MVT::ValueType VT) {
SDNode *N = new SDNode(Opcode, VT); SDNode *&N = NullaryOps[std::make_pair(Opcode, VT)];
AllNodes.push_back(N); if (!N) {
N = new SDNode(Opcode, VT);
AllNodes.push_back(N);
}
return SDOperand(N, 0); return SDOperand(N, 0);
} }