[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

Evan Cheng evan.cheng at apple.com
Wed Jan 18 17:55:57 PST 2006



Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.135 -> 1.136
---
Log message:

Prevent unnecessary CopyToReg when the same HW register appears in two spots
in the pattern.


---
Diffs of the changes:  (+9 -0)

 DAGISelEmitter.cpp |    9 +++++++++
 1 files changed, 9 insertions(+)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.135 llvm/utils/TableGen/DAGISelEmitter.cpp:1.136
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.135	Tue Jan 17 01:36:41 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp	Wed Jan 18 19:55:45 2006
@@ -1835,6 +1835,7 @@
   std::map<std::string, Record*> OperatorMap;
   // Names of all the folded nodes which produce chains.
   std::vector<std::pair<std::string, unsigned> > FoldedChains;
+  std::set<std::string> Duplicates;
   unsigned TmpNo;
 
 public:
@@ -1952,6 +1953,7 @@
             // previously named thing.
             OS << "      if (" << VarMapEntry << " != " << RootName << OpNo
                << ") goto P" << PatternNo << "Fail;\n";
+            Duplicates.insert(RootName + utostr(OpNo));
             continue;
           }
         }
@@ -2351,6 +2353,13 @@
         EmitCopyToRegs(Child, RootName + utostr(OpNo), ChainEmitted);
       } else {
         if (DefInit *DI = dynamic_cast<DefInit*>(Child->getLeafValue())) {
+          if (!Child->getName().empty()) {
+            std::string Name = RootName + utostr(OpNo);
+            if (Duplicates.find(Name) != Duplicates.end())
+              // A duplicate! Do not emit a copy for this node.
+              continue;
+          }
+
           Record *RR = DI->getDef();
           if (RR->isSubClassOf("Register")) {
             MVT::ValueType RVT = getRegisterValueType(RR, T);






More information about the llvm-commits mailing list