Relax this check.
authorChris Lattner <sabre@nondot.org>
Thu, 14 Sep 2006 23:54:24 +0000 (23:54 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 14 Sep 2006 23:54:24 +0000 (23:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30381 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/DAGISelEmitter.cpp

index c8dd50e9c444991178a413b4ffde1486f2da21aa..4d4fa9dabd011198c4777bf0347d22f41e5e3c69 100644 (file)
@@ -824,13 +824,16 @@ bool TreePatternNode::canPatternMatch(std::string &Reason, DAGISelEmitter &ISE){
   const SDNodeInfo &NodeInfo = ISE.getSDNodeInfo(getOperator());
   if (NodeInfo.hasProperty(SDNodeInfo::SDNPCommutative)) {
     // Scan all of the operands of the node and make sure that only the last one
-    // is a constant node.
-    for (unsigned i = 0, e = getNumChildren()-1; i != e; ++i)
-      if (!getChild(i)->isLeaf() && 
-          getChild(i)->getOperator()->getName() == "imm") {
-        Reason = "Immediate value must be on the RHS of commutative operators!";
-        return false;
-      }
+    // is a constant node, unless the RHS also is.
+    if (getChild(getNumChildren()-1)->isLeaf() ||
+        getChild(getNumChildren()-1)->getOperator()->getName() != "imm") {
+      for (unsigned i = 0, e = getNumChildren()-1; i != e; ++i)
+        if (!getChild(i)->isLeaf() && 
+            getChild(i)->getOperator()->getName() == "imm") {
+          Reason = "Immediate value must be on the RHS of commutative operators!";
+          return false;
+        }
+    }
   }
   
   return true;