1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 19:52:54 +01:00

Prevent folding of instructions which produce chains that have more than 1 real use

llvm-svn: 24643
This commit is contained in:
Evan Cheng 2005-12-09 06:06:08 +00:00
parent 1d7435f478
commit 18134d8c96
2 changed files with 9 additions and 4 deletions

View File

@ -1691,11 +1691,12 @@ struct PatternSortingPredicate {
/// matches, and the SDNode for the result has the RootName specified name.
void DAGISelEmitter::EmitMatchForPattern(TreePatternNode *N,
const std::string &RootName,
std::map<std::string,std::string> &VarMap,
std::map<std::string,std::string> &VarMap,
unsigned PatternNo,
std::ostream &OS,
std::string &ChainName,
bool &HasChain, bool &InFlag) {
bool &HasChain, bool &InFlag,
bool isRoot) {
if (N->isLeaf()) {
if (IntInit *II = dynamic_cast<IntInit*>(N->getLeafValue())) {
OS << " if (cast<ConstantSDNode>(" << RootName
@ -1731,6 +1732,10 @@ void DAGISelEmitter::EmitMatchForPattern(TreePatternNode *N,
if (NodeHasChain(N, *this)) {
OpNo = 1;
if (!isRoot) {
OS << " if (" << RootName << ".hasOneUse()) goto P"
<< PatternNo << "Fail;\n";
}
if (!HasChain) {
HasChain = true;
OS << " SDOperand " << RootName << "0 = " << RootName
@ -2143,7 +2148,7 @@ void DAGISelEmitter::EmitCodeForPattern(PatternToMatch &Pattern,
std::map<std::string,std::string> VariableMap;
std::string ChainName;
EmitMatchForPattern(Pattern.first, "N", VariableMap, PatternNo, OS,
ChainName, HasChain, InFlag);
ChainName, HasChain, InFlag, true /*the root*/);
// TP - Get *SOME* tree pattern, we don't care which.
TreePattern &TP = *PatternFragments.begin()->second;

View File

@ -425,7 +425,7 @@ private:
std::map<std::string,std::string> &VarMap,
unsigned PatternNo, std::ostream &OS,
std::string &ChainName,
bool &HasChain, bool &InFlag);
bool &HasChain, bool &InFlag, bool isRoot = false);
void EmitCopyToRegsForPattern(TreePatternNode *N, const std::string &RootName,
std::ostream &OS, bool HasChain);
std::pair<unsigned, unsigned>