[llvm] r354763 - [SelectionDAG] Add a OPC_CheckChild2CondCode to SelectionDAGISel to remove a MoveChild and MoveParent pair.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 24 19:11:44 PST 2019
Author: ctopper
Date: Sun Feb 24 19:11:44 2019
New Revision: 354763
URL: http://llvm.org/viewvc/llvm-project?rev=354763&view=rev
Log:
[SelectionDAG] Add a OPC_CheckChild2CondCode to SelectionDAGISel to remove a MoveChild and MoveParent pair.
OPC_CheckCondCode is always used as operand 2 of a setcc. And its always surrounded by a MoveChild2 and a MoveParent. By having a dedicated opcode for this case we can reduce the number of bytes needed for this pattern from 4 bytes to 2.
This saves ~3000 bytes in the X86 table.
Modified:
llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
llvm/trunk/utils/TableGen/DAGISelMatcher.cpp
llvm/trunk/utils/TableGen/DAGISelMatcher.h
llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp
llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp
Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h?rev=354763&r1=354762&r2=354763&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h Sun Feb 24 19:11:44 2019
@@ -143,7 +143,7 @@ public:
OPC_CheckInteger,
OPC_CheckChild0Integer, OPC_CheckChild1Integer, OPC_CheckChild2Integer,
OPC_CheckChild3Integer, OPC_CheckChild4Integer,
- OPC_CheckCondCode,
+ OPC_CheckCondCode, OPC_CheckChild2CondCode,
OPC_CheckValueType,
OPC_CheckComplexPat,
OPC_CheckAndImm, OPC_CheckOrImm,
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=354763&r1=354762&r2=354763&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Sun Feb 24 19:11:44 2019
@@ -2757,6 +2757,14 @@ CheckCondCode(const unsigned char *Match
}
LLVM_ATTRIBUTE_ALWAYS_INLINE static inline bool
+CheckChild2CondCode(const unsigned char *MatcherTable, unsigned &MatcherIndex,
+ SDValue N) {
+ if (2 >= N.getNumOperands())
+ return false;
+ return ::CheckCondCode(MatcherTable, MatcherIndex, N.getOperand(2));
+}
+
+LLVM_ATTRIBUTE_ALWAYS_INLINE static inline bool
CheckValueType(const unsigned char *MatcherTable, unsigned &MatcherIndex,
SDValue N, const TargetLowering *TLI, const DataLayout &DL) {
MVT::SimpleValueType VT = (MVT::SimpleValueType)MatcherTable[MatcherIndex++];
@@ -2871,6 +2879,9 @@ static unsigned IsPredicateKnownToFail(c
case SelectionDAGISel::OPC_CheckCondCode:
Result = !::CheckCondCode(Table, Index, N);
return Index;
+ case SelectionDAGISel::OPC_CheckChild2CondCode:
+ Result = !::CheckChild2CondCode(Table, Index, N);
+ return Index;
case SelectionDAGISel::OPC_CheckValueType:
Result = !::CheckValueType(Table, Index, N, SDISel.TLI,
SDISel.CurDAG->getDataLayout());
@@ -3359,6 +3370,9 @@ void SelectionDAGISel::SelectCodeCommon(
case OPC_CheckCondCode:
if (!::CheckCondCode(MatcherTable, MatcherIndex, N)) break;
continue;
+ case OPC_CheckChild2CondCode:
+ if (!::CheckChild2CondCode(MatcherTable, MatcherIndex, N)) break;
+ continue;
case OPC_CheckValueType:
if (!::CheckValueType(MatcherTable, MatcherIndex, N, TLI,
CurDAG->getDataLayout()))
Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.cpp?rev=354763&r1=354762&r2=354763&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelMatcher.cpp (original)
+++ llvm/trunk/utils/TableGen/DAGISelMatcher.cpp Sun Feb 24 19:11:44 2019
@@ -211,6 +211,11 @@ void CheckCondCodeMatcher::printImpl(raw
OS.indent(indent) << "CheckCondCode ISD::" << CondCodeName << '\n';
}
+void CheckChild2CondCodeMatcher::printImpl(raw_ostream &OS,
+ unsigned indent) const {
+ OS.indent(indent) << "CheckChild2CondCode ISD::" << CondCodeName << '\n';
+}
+
void CheckValueTypeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
OS.indent(indent) << "CheckValueType MVT::" << TypeName << '\n';
}
Modified: llvm/trunk/utils/TableGen/DAGISelMatcher.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcher.h?rev=354763&r1=354762&r2=354763&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelMatcher.h (original)
+++ llvm/trunk/utils/TableGen/DAGISelMatcher.h Sun Feb 24 19:11:44 2019
@@ -66,6 +66,7 @@ public:
CheckInteger, // Fail if wrong val.
CheckChildInteger, // Fail if child is wrong val.
CheckCondCode, // Fail if not condcode.
+ CheckChild2CondCode, // Fail if child is wrong condcode.
CheckValueType,
CheckComplexPat,
CheckAndImm,
@@ -121,6 +122,7 @@ public:
case CheckInteger:
case CheckChildInteger:
case CheckCondCode:
+ case CheckChild2CondCode:
case CheckValueType:
case CheckAndImm:
case CheckOrImm:
@@ -625,6 +627,27 @@ private:
}
};
+/// CheckChild2CondCodeMatcher - This checks to see if child 2 node is a
+/// CondCodeSDNode with the specified condition, if not it fails to match.
+class CheckChild2CondCodeMatcher : public Matcher {
+ StringRef CondCodeName;
+public:
+ CheckChild2CondCodeMatcher(StringRef condcodename)
+ : Matcher(CheckChild2CondCode), CondCodeName(condcodename) {}
+
+ StringRef getCondCodeName() const { return CondCodeName; }
+
+ static bool classof(const Matcher *N) {
+ return N->getKind() == CheckChild2CondCode;
+ }
+
+private:
+ void printImpl(raw_ostream &OS, unsigned indent) const override;
+ bool isEqualImpl(const Matcher *M) const override {
+ return cast<CheckChild2CondCodeMatcher>(M)->CondCodeName == CondCodeName;
+ }
+};
+
/// CheckValueTypeMatcher - This checks to see if the current node is a
/// VTSDNode with the specified type, if not it fails to match.
class CheckValueTypeMatcher : public Matcher {
Modified: llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp?rev=354763&r1=354762&r2=354763&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/DAGISelMatcherEmitter.cpp Sun Feb 24 19:11:44 2019
@@ -554,6 +554,11 @@ EmitMatcher(const Matcher *N, unsigned I
<< cast<CheckCondCodeMatcher>(N)->getCondCodeName() << ",\n";
return 2;
+ case Matcher::CheckChild2CondCode:
+ OS << "OPC_CheckChild2CondCode, ISD::"
+ << cast<CheckChild2CondCodeMatcher>(N)->getCondCodeName() << ",\n";
+ return 2;
+
case Matcher::CheckValueType:
OS << "OPC_CheckValueType, MVT::"
<< cast<CheckValueTypeMatcher>(N)->getTypeName() << ",\n";
@@ -995,6 +1000,7 @@ static StringRef getOpcodeString(Matcher
case Matcher::CheckInteger: return "OPC_CheckInteger"; break;
case Matcher::CheckChildInteger: return "OPC_CheckChildInteger"; break;
case Matcher::CheckCondCode: return "OPC_CheckCondCode"; break;
+ case Matcher::CheckChild2CondCode: return "OPC_CheckChild2CondCode"; break;
case Matcher::CheckValueType: return "OPC_CheckValueType"; break;
case Matcher::CheckComplexPat: return "OPC_CheckComplexPat"; break;
case Matcher::CheckAndImm: return "OPC_CheckAndImm"; break;
Modified: llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp?rev=354763&r1=354762&r2=354763&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp (original)
+++ llvm/trunk/utils/TableGen/DAGISelMatcherOpt.cpp Sun Feb 24 19:11:44 2019
@@ -55,9 +55,13 @@ static void ContractNodes(std::unique_pt
if (MC->getChildNo() < 4) // Only have CheckChildSame0...3
New = new CheckChildSameMatcher(MC->getChildNo(), CS->getMatchNumber());
- if (CheckIntegerMatcher *CS = dyn_cast<CheckIntegerMatcher>(MC->getNext()))
+ if (CheckIntegerMatcher *CI = dyn_cast<CheckIntegerMatcher>(MC->getNext()))
if (MC->getChildNo() < 5) // Only have CheckChildInteger0...4
- New = new CheckChildIntegerMatcher(MC->getChildNo(), CS->getValue());
+ New = new CheckChildIntegerMatcher(MC->getChildNo(), CI->getValue());
+
+ if (auto *CCC = dyn_cast<CheckCondCodeMatcher>(MC->getNext()))
+ if (MC->getChildNo() == 2) // Only have CheckChild2CondCode
+ New = new CheckChild2CondCodeMatcher(CCC->getCondCodeName());
if (New) {
// Insert the new node.
More information about the llvm-commits
mailing list