Split SelectionDAGISel::IsLegalAndProfitableToFold to
[oota-llvm.git] / utils / TableGen / DAGISelEmitter.cpp
index 0eb06bb5412cb8fb16d5011202354d2bbc2bcb89..d2e260e2e7e56ed445ba053de65f1faac6b0966f 100644 (file)
@@ -566,8 +566,11 @@ void PatternCodeEmitter::EmitMatchCode(TreePatternNode *N, TreePatternNode *P,
     if (NodeHasChain)
       OpNo = 1;
     if (!isRoot) {
-      // Multiple uses of actual result?
-      emitCheck(getValueName(RootName) + ".hasOneUse()");
+      // 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)");
       EmittedUseCheck = true;
       if (NodeHasChain) {
         // If the immediate use can somehow reach this node through another
@@ -597,8 +600,7 @@ void PatternCodeEmitter::EmitMatchCode(TreePatternNode *N, TreePatternNode *P,
         }
         
         if (NeedCheck) {
-          std::string ParentName(RootName.begin(), RootName.end()-1);
-          emitCheck("IsLegalAndProfitableToFold(" + getNodeName(RootName) +
+          emitCheck("IsLegalToFold(" + getValueName(RootName) +
                     ", " + getNodeName(ParentName) + ", N)");
         }
       }