diff options
author | Chris Lattner <sabre@nondot.org> | 2010-02-16 19:03:34 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-02-16 19:03:34 +0000 |
commit | 29c6270328cf1dad1dee063990015a4c9b583e1f (patch) | |
tree | d66563680feebf0b83a670eb5f105f47f3f9af91 /utils/TableGen/DAGISelEmitter.cpp | |
parent | 1665b0a2246c83a2c123be105a1a167cf2b423fe (diff) | |
download | llvm-29c6270328cf1dad1dee063990015a4c9b583e1f.tar.gz llvm-29c6270328cf1dad1dee063990015a4c9b583e1f.tar.bz2 llvm-29c6270328cf1dad1dee063990015a4c9b583e1f.tar.xz |
change dag isel emitter to only call 'IsProfitableToFold' on nodes
with chains. On interior nodes that lead up to them, we just directly
check that there is a single use. This generates slightly more
efficient code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96366 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/DAGISelEmitter.cpp')
-rw-r--r-- | utils/TableGen/DAGISelEmitter.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp index f0cebeddd3..e1d09a8949 100644 --- a/utils/TableGen/DAGISelEmitter.cpp +++ b/utils/TableGen/DAGISelEmitter.cpp @@ -568,9 +568,12 @@ void PatternCodeEmitter::EmitMatchCode(TreePatternNode *N, TreePatternNode *P, // Check if it's profitable to fold the node. e.g. Check for multiple uses // of actual result? std::string ParentName(RootName.begin(), RootName.end()-1); - emitCheck("IsProfitableToFold(" + getValueName(RootName) + - ", " + getNodeName(ParentName) + ", N)"); - if (NodeHasChain) { + if (!NodeHasChain) { + // If this is just an interior node, check to see if it has a single + // use. If the node has multiple uses and the pattern has a load as + // an operand, then we can't fold the load. + emitCheck(getValueName(RootName) + ".hasOneUse()"); + } else { // If the immediate use can somehow reach this node through another // path, then can't fold it either or it will create a cycle. // e.g. In the following diagram, XX can reach ld through YY. If @@ -588,6 +591,8 @@ void PatternCodeEmitter::EmitMatchCode(TreePatternNode *N, TreePatternNode *P, // We know we need the check if N's parent is not the root. bool NeedCheck = P != Pattern; if (!NeedCheck) { + // If the parent is the root and the node has more than one operand, + // we need to check. const SDNodeInfo &PInfo = CGP.getSDNodeInfo(P->getOperator()); NeedCheck = P->getOperator() == CGP.get_intrinsic_void_sdnode() || @@ -600,8 +605,13 @@ void PatternCodeEmitter::EmitMatchCode(TreePatternNode *N, TreePatternNode *P, } if (NeedCheck) { + emitCheck("IsProfitableToFold(" + getValueName(RootName) + + ", " + getNodeName(ParentName) + ", N)"); emitCheck("IsLegalToFold(" + getValueName(RootName) + ", " + getNodeName(ParentName) + ", N)"); + } else { + // Otherwise, just verify that the node only has a single use. + emitCheck(getValueName(RootName) + ".hasOneUse()"); } } } |