llvm.org GIT mirror llvm / 4a7c284
Pattern complexity calculation fix. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25133 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 13 years ago
1 changed file(s) with 9 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
16901690 /// patterns before small ones. This is used to determine the size of a
16911691 /// pattern.
16921692 static unsigned getPatternSize(TreePatternNode *P, DAGISelEmitter &ISE) {
1693 assert(isExtIntegerInVTs(P->getExtTypes()) ||
1694 isExtFloatingPointInVTs(P->getExtTypes()) ||
1695 P->getExtTypeNum(0) == MVT::isVoid ||
1696 P->getExtTypeNum(0) == MVT::Flag &&
1697 "Not a valid pattern node to size!");
16931698 unsigned Size = 2; // The node itself.
16941699
16951700 // FIXME: This is a hack to statically increase the priority of patterns
16991704 // calculate the complexity of all patterns a dag can potentially map to.
17001705 const ComplexPattern *AM = NodeGetComplexPattern(P, ISE);
17011706 if (AM)
1702 Size += AM->getNumOperands();
1707 Size += AM->getNumOperands() * 2;
17031708
17041709 // Count children in the count if they are also nodes.
17051710 for (unsigned i = 0, e = P->getNumChildren(); i != e; ++i) {
17071712 if (!Child->isLeaf() && Child->getExtTypeNum(0) != MVT::Other)
17081713 Size += getPatternSize(Child, ISE);
17091714 else if (Child->isLeaf()) {
1710 Size += getPatternSize(Child, ISE);
17111715 if (dynamic_cast(Child->getLeafValue()))
1712 // Matches a ConstantSDNode. More specific to any immediate.
1713 ++Size;
1716 Size += 3; // Matches a ConstantSDNode.
1717 else if (NodeIsComplexPattern(Child))
1718 Size += getPatternSize(Child, ISE);
17141719 }
17151720 }
17161721