Fold single use token factor nodes into other token factor nodes.

llvm-svn: 19701
This commit is contained in:
Chris Lattner 2005-01-19 19:10:54 +00:00
parent 0d03eb45a8
commit 55562fa99a
1 changed files with 10 additions and 2 deletions

View File

@ -264,8 +264,16 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
std::vector<SDOperand> Ops;
bool Changed = false;
for (unsigned i = 0, e = Node->getNumOperands(); i != e; ++i) {
Ops.push_back(LegalizeOp(Node->getOperand(i))); // Legalize the operands
Changed |= Ops[i] != Node->getOperand(i);
SDOperand Op = Node->getOperand(i);
// Fold single-use TokenFactor nodes into this token factor as we go.
if (Op.getOpcode() == ISD::TokenFactor && Op.hasOneUse()) {
Changed = true;
for (unsigned j = 0, e = Op.getNumOperands(); j != e; ++j)
Ops.push_back(LegalizeOp(Op.getOperand(j)));
} else {
Ops.push_back(LegalizeOp(Op)); // Legalize the operands
Changed |= Ops[i] != Op;
}
}
if (Changed)
Result = DAG.getNode(ISD::TokenFactor, MVT::Other, Ops);