SDOperand Node = Worklist.back();
Worklist.pop_back();
+ // Chose from the least deep of the top two nodes.
+ if (!Worklist.empty() &&
+ Worklist.back().Val->getNodeDepth() < Node.Val->getNodeDepth())
+ std::swap(Worklist.back(), Node);
+
if ((Node.Val->getOpcode() >= ISD::BUILTIN_OP_END &&
Node.Val->getOpcode() < PPCISD::FIRST_NUMBER) ||
CodeGenMap.count(Node)) continue;
// Finally, legalize this node.
Select(Node);
}
-
+
// Select target instructions for the DAG.
DAG.setRoot(Select(DAG.getRoot()));
CodeGenMap.clear();
New = CurDAG->getNode(ISD::TokenFactor, MVT::Other, Ops);
}
- if (!N->hasOneUse()) CodeGenMap[Op] = New;
+ CodeGenMap[Op] = New;
return New;
}
case ISD::CopyFromReg: {
SDOperand Val = Select(N->getOperand(2));
SDOperand New = CurDAG->getNode(ISD::CopyToReg, MVT::Other,
Chain, Reg, Val);
- if (!N->hasOneUse()) CodeGenMap[Op] = New;
+ CodeGenMap[Op] = New;
return New;
}
case ISD::UNDEF:
Select(N->getOperand(0)));
return SDOperand(N, 0);
}
-
case ISD::LOAD:
case ISD::EXTLOAD:
case ISD::ZEXTLOAD:
return Ext;
}
}
-
case ISD::TRUNCSTORE:
case ISD::STORE: {
SDOperand AddrOp1, AddrOp2;