[llvm] 6111f5c - [SelectionDAG] Add instantiated OPC_CheckChildType (#73297)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 12 01:31:15 PST 2023
Author: Wang Pengcheng
Date: 2023-12-12T17:31:12+08:00
New Revision: 6111f5c5925cb40357e2a972ebae4294731c307f
URL: https://github.com/llvm/llvm-project/commit/6111f5c5925cb40357e2a972ebae4294731c307f
DIFF: https://github.com/llvm/llvm-project/commit/6111f5c5925cb40357e2a972ebae4294731c307f.diff
LOG: [SelectionDAG] Add instantiated OPC_CheckChildType (#73297)
The most common type is i32 or i64 so we add `OPC_CheckChildTypeI32`
and `OPC_CheckChildTypeI64` to save one byte.
Overall this reduces the llc binary size with all in-tree targets by
about 70K.
Added:
Modified:
llvm/include/llvm/CodeGen/SelectionDAGISel.h
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/SelectionDAGISel.h b/llvm/include/llvm/CodeGen/SelectionDAGISel.h
index ca3d0340862907..9b3a2352fb1ad0 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAGISel.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAGISel.h
@@ -169,6 +169,25 @@ class SelectionDAGISel : public MachineFunctionPass {
OPC_CheckChild5Type,
OPC_CheckChild6Type,
OPC_CheckChild7Type,
+
+ OPC_CheckChild0TypeI32,
+ OPC_CheckChild1TypeI32,
+ OPC_CheckChild2TypeI32,
+ OPC_CheckChild3TypeI32,
+ OPC_CheckChild4TypeI32,
+ OPC_CheckChild5TypeI32,
+ OPC_CheckChild6TypeI32,
+ OPC_CheckChild7TypeI32,
+
+ OPC_CheckChild0TypeI64,
+ OPC_CheckChild1TypeI64,
+ OPC_CheckChild2TypeI64,
+ OPC_CheckChild3TypeI64,
+ OPC_CheckChild4TypeI64,
+ OPC_CheckChild5TypeI64,
+ OPC_CheckChild6TypeI64,
+ OPC_CheckChild7TypeI64,
+
OPC_CheckInteger,
OPC_CheckChild0Integer,
OPC_CheckChild1Integer,
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 9c423dba7d2c21..cba25b8d7c02a4 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -2885,11 +2885,39 @@ static unsigned IsPredicateKnownToFail(const unsigned char *Table,
case SelectionDAGISel::OPC_CheckChild4Type:
case SelectionDAGISel::OPC_CheckChild5Type:
case SelectionDAGISel::OPC_CheckChild6Type:
- case SelectionDAGISel::OPC_CheckChild7Type: {
- Result =
- !::CheckChildType(static_cast<MVT::SimpleValueType>(Table[Index++]), N,
- SDISel.TLI, SDISel.CurDAG->getDataLayout(),
- Opcode - SelectionDAGISel::OPC_CheckChild0Type);
+ case SelectionDAGISel::OPC_CheckChild7Type:
+ case SelectionDAGISel::OPC_CheckChild0TypeI32:
+ case SelectionDAGISel::OPC_CheckChild1TypeI32:
+ case SelectionDAGISel::OPC_CheckChild2TypeI32:
+ case SelectionDAGISel::OPC_CheckChild3TypeI32:
+ case SelectionDAGISel::OPC_CheckChild4TypeI32:
+ case SelectionDAGISel::OPC_CheckChild5TypeI32:
+ case SelectionDAGISel::OPC_CheckChild6TypeI32:
+ case SelectionDAGISel::OPC_CheckChild7TypeI32:
+ case SelectionDAGISel::OPC_CheckChild0TypeI64:
+ case SelectionDAGISel::OPC_CheckChild1TypeI64:
+ case SelectionDAGISel::OPC_CheckChild2TypeI64:
+ case SelectionDAGISel::OPC_CheckChild3TypeI64:
+ case SelectionDAGISel::OPC_CheckChild4TypeI64:
+ case SelectionDAGISel::OPC_CheckChild5TypeI64:
+ case SelectionDAGISel::OPC_CheckChild6TypeI64:
+ case SelectionDAGISel::OPC_CheckChild7TypeI64: {
+ MVT::SimpleValueType VT;
+ unsigned ChildNo;
+ if (Opcode >= SelectionDAGISel::OPC_CheckChild0TypeI32 &&
+ Opcode <= SelectionDAGISel::OPC_CheckChild7TypeI32) {
+ VT = MVT::i32;
+ ChildNo = Opcode - SelectionDAGISel::OPC_CheckChild0TypeI32;
+ } else if (Opcode >= SelectionDAGISel::OPC_CheckChild0TypeI64 &&
+ Opcode <= SelectionDAGISel::OPC_CheckChild7TypeI64) {
+ VT = MVT::i64;
+ ChildNo = Opcode - SelectionDAGISel::OPC_CheckChild0TypeI64;
+ } else {
+ VT = static_cast<MVT::SimpleValueType>(Table[Index++]);
+ ChildNo = Opcode - SelectionDAGISel::OPC_CheckChild0Type;
+ }
+ Result = !::CheckChildType(VT, N, SDISel.TLI,
+ SDISel.CurDAG->getDataLayout(), ChildNo);
return Index;
}
case SelectionDAGISel::OPC_CheckCondCode:
@@ -3412,15 +3440,48 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
<< '\n');
continue;
}
- case OPC_CheckChild0Type: case OPC_CheckChild1Type:
- case OPC_CheckChild2Type: case OPC_CheckChild3Type:
- case OPC_CheckChild4Type: case OPC_CheckChild5Type:
- case OPC_CheckChild6Type: case OPC_CheckChild7Type:
- if (!::CheckChildType(
- static_cast<MVT::SimpleValueType>(MatcherTable[MatcherIndex++]),
- N, TLI, CurDAG->getDataLayout(), Opcode - OPC_CheckChild0Type))
+ case OPC_CheckChild0Type:
+ case OPC_CheckChild1Type:
+ case OPC_CheckChild2Type:
+ case OPC_CheckChild3Type:
+ case OPC_CheckChild4Type:
+ case OPC_CheckChild5Type:
+ case OPC_CheckChild6Type:
+ case OPC_CheckChild7Type:
+ case OPC_CheckChild0TypeI32:
+ case OPC_CheckChild1TypeI32:
+ case OPC_CheckChild2TypeI32:
+ case OPC_CheckChild3TypeI32:
+ case OPC_CheckChild4TypeI32:
+ case OPC_CheckChild5TypeI32:
+ case OPC_CheckChild6TypeI32:
+ case OPC_CheckChild7TypeI32:
+ case OPC_CheckChild0TypeI64:
+ case OPC_CheckChild1TypeI64:
+ case OPC_CheckChild2TypeI64:
+ case OPC_CheckChild3TypeI64:
+ case OPC_CheckChild4TypeI64:
+ case OPC_CheckChild5TypeI64:
+ case OPC_CheckChild6TypeI64:
+ case OPC_CheckChild7TypeI64: {
+ MVT::SimpleValueType VT;
+ unsigned ChildNo;
+ if (Opcode >= SelectionDAGISel::OPC_CheckChild0TypeI32 &&
+ Opcode <= SelectionDAGISel::OPC_CheckChild7TypeI32) {
+ VT = MVT::i32;
+ ChildNo = Opcode - SelectionDAGISel::OPC_CheckChild0TypeI32;
+ } else if (Opcode >= SelectionDAGISel::OPC_CheckChild0TypeI64 &&
+ Opcode <= SelectionDAGISel::OPC_CheckChild7TypeI64) {
+ VT = MVT::i64;
+ ChildNo = Opcode - SelectionDAGISel::OPC_CheckChild0TypeI64;
+ } else {
+ VT = static_cast<MVT::SimpleValueType>(MatcherTable[MatcherIndex++]);
+ ChildNo = Opcode - SelectionDAGISel::OPC_CheckChild0Type;
+ }
+ if (!::CheckChildType(VT, N, TLI, CurDAG->getDataLayout(), ChildNo))
break;
continue;
+ }
case OPC_CheckCondCode:
if (!::CheckCondCode(MatcherTable, MatcherIndex, N)) break;
continue;
diff --git a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
index 22bf5926966da6..5f79e2ad0df294 100644
--- a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
@@ -593,11 +593,20 @@ EmitMatcher(const Matcher *N, const unsigned Indent, unsigned CurrentIdx,
<< ", " << getEnumName(cast<CheckTypeMatcher>(N)->getType()) << ",\n";
return 3;
- case Matcher::CheckChildType:
- OS << "OPC_CheckChild"
- << cast<CheckChildTypeMatcher>(N)->getChildNo() << "Type, "
- << getEnumName(cast<CheckChildTypeMatcher>(N)->getType()) << ",\n";
- return 2;
+ case Matcher::CheckChildType: {
+ MVT::SimpleValueType VT = cast<CheckChildTypeMatcher>(N)->getType();
+ switch (VT) {
+ case MVT::i32:
+ case MVT::i64:
+ OS << "OPC_CheckChild" << cast<CheckChildTypeMatcher>(N)->getChildNo()
+ << "TypeI" << MVT(VT).getScalarSizeInBits() << ",\n";
+ return 1;
+ default:
+ OS << "OPC_CheckChild" << cast<CheckChildTypeMatcher>(N)->getChildNo()
+ << "Type, " << getEnumName(VT) << ",\n";
+ return 2;
+ }
+ }
case Matcher::CheckInteger: {
OS << "OPC_CheckInteger, ";
More information about the llvm-commits
mailing list