aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-09-14 23:54:24 +0000
committerChris Lattner <sabre@nondot.org>2006-09-14 23:54:24 +0000
commit7905c55b12bd5bff95304e3e7152d7a41ec8a78c (patch)
tree56b5ba19ba83562c0c3726f0c21de4be8fbaae9d
parent697e5905805634b343be39391c403c38d2e64999 (diff)
Relax this check.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30381 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--utils/TableGen/DAGISelEmitter.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp
index c8dd50e9c4..4d4fa9dabd 100644
--- a/utils/TableGen/DAGISelEmitter.cpp
+++ b/utils/TableGen/DAGISelEmitter.cpp
@@ -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;