forked from OSchip/llvm-project
node predicates add to the complexity of a pattern. This ensures that the
X86 backend attempts to match small-immediate versions of instructions before the full size immediate versions. llvm-svn: 25937
This commit is contained in:
parent
ca76917388
commit
2bcfc52af6
llvm/utils/TableGen
|
@ -1722,7 +1722,12 @@ static unsigned getPatternSize(TreePatternNode *P, DAGISelEmitter &ISE) {
|
||||||
const ComplexPattern *AM = NodeGetComplexPattern(P, ISE);
|
const ComplexPattern *AM = NodeGetComplexPattern(P, ISE);
|
||||||
if (AM)
|
if (AM)
|
||||||
Size += AM->getNumOperands() * 2;
|
Size += AM->getNumOperands() * 2;
|
||||||
|
|
||||||
|
// If this node has some predicate function that must match, it adds to the
|
||||||
|
// complexity of this node.
|
||||||
|
if (!P->getPredicateFn().empty())
|
||||||
|
++Size;
|
||||||
|
|
||||||
// Count children in the count if they are also nodes.
|
// Count children in the count if they are also nodes.
|
||||||
for (unsigned i = 0, e = P->getNumChildren(); i != e; ++i) {
|
for (unsigned i = 0, e = P->getNumChildren(); i != e; ++i) {
|
||||||
TreePatternNode *Child = P->getChild(i);
|
TreePatternNode *Child = P->getChild(i);
|
||||||
|
@ -1730,9 +1735,11 @@ static unsigned getPatternSize(TreePatternNode *P, DAGISelEmitter &ISE) {
|
||||||
Size += getPatternSize(Child, ISE);
|
Size += getPatternSize(Child, ISE);
|
||||||
else if (Child->isLeaf()) {
|
else if (Child->isLeaf()) {
|
||||||
if (dynamic_cast<IntInit*>(Child->getLeafValue()))
|
if (dynamic_cast<IntInit*>(Child->getLeafValue()))
|
||||||
Size += 3; // Matches a ConstantSDNode.
|
Size += 3; // Matches a ConstantSDNode (+2) and a specific value (+1).
|
||||||
else if (NodeIsComplexPattern(Child))
|
else if (NodeIsComplexPattern(Child))
|
||||||
Size += getPatternSize(Child, ISE);
|
Size += getPatternSize(Child, ISE);
|
||||||
|
else if (!Child->getPredicateFn().empty())
|
||||||
|
++Size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue