teach the optimizer that opcode == ISD::STORE is contradictory
authorChris Lattner <sabre@nondot.org>
Sat, 27 Feb 2010 08:11:15 +0000 (08:11 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 27 Feb 2010 08:11:15 +0000 (08:11 +0000)
with getType() == MVT::i32 etc.  Teach it that two different
integer constants are contradictory.  This cuts 1K off the X86
table, down to 98k

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97314 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/DAGISelMatcher.cpp
utils/TableGen/DAGISelMatcher.h
utils/TableGen/DAGISelMatcherOpt.cpp

index dfb2361415046ab9772febfbc21a9095f0dc00ec..601ac87ea46feb35b704f4532d12a45c5fab4be2 100644 (file)
@@ -267,7 +267,12 @@ bool CheckOpcodeMatcher::isContradictoryImpl(const Matcher *M) const {
   }
   
   // TODO: CheckMultiOpcodeMatcher?
-  // TODO: CheckType?
+  
+  // This is a special common case we see a lot in the X86 backend, we know that
+  // ISD::STORE nodes can't have non-void type.
+  if (const CheckTypeMatcher *CT = dyn_cast<CheckTypeMatcher>(M))
+    return getOpcodeName() == "ISD::STORE" && CT->getType() != MVT::isVoid;
+  
   return false;
 }
 
@@ -307,4 +312,8 @@ bool CheckChildTypeMatcher::isContradictoryImpl(const Matcher *M) const {
   return false;
 }
   
-
+bool CheckIntegerMatcher::isContradictoryImpl(const Matcher *M) const {
+  if (const CheckIntegerMatcher *CIM = dyn_cast<CheckIntegerMatcher>(M))
+    return CIM->getValue() != getValue();
+  return false;
+}
index b4de0e4fcf01ec7f4aa39f51b6a2eadeb160972a..f983f5a133b34d8f20083e613d07921554c8f23a 100644 (file)
@@ -511,6 +511,7 @@ private:
     return cast<CheckIntegerMatcher>(M)->Value == Value;
   }
   virtual unsigned getHashImpl() const { return Value; }
+  virtual bool isContradictoryImpl(const Matcher *M) const;
 };
   
 /// CheckCondCodeMatcher - This checks to see if the current node is a
index 045d5011e7030ba65a06c28b895ac15f1c5c9eb4..d475dad49655df276556633d7909ed3042535ad6 100644 (file)
@@ -202,14 +202,14 @@ static void FactorNodes(OwningPtr<Matcher> &MatcherPtr) {
     }
       
     if (Scan != e) {
-      DEBUG(errs() << "Couldn't merge this:\n  ";
-            Optn->printOne(errs());
-            errs() << "into this:\n  ";
-            OptionsToMatch[OptionIdx]->printOne(errs());
+      DEBUG(errs() << "Couldn't merge this:\n";
+            Optn->print(errs(), 4);
+            errs() << "into this:\n";
+            OptionsToMatch[Scan]->print(errs(), 4);
             if (OptionIdx+1 != e)
-              OptionsToMatch[OptionIdx+1]->printOne(errs());
+              OptionsToMatch[Scan+1]->printOne(errs());
             if (OptionIdx+2 < e)
-              OptionsToMatch[OptionIdx+2]->printOne(errs());
+              OptionsToMatch[Scan+2]->printOne(errs());
             errs() << "\n");
     }