[llvm] [SelectionDAG] Encode frequent ISD opcode checks directly (PR #202634)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 9 07:04:33 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- llvm/include/llvm/CodeGen/SelectionDAGISel.h llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp llvm/utils/TableGen/DAGISelMatcherEmitter.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index a80518250..0020255b3 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -3053,8 +3053,7 @@ static constexpr uint16_t CompactISDOpcodes[] = {
 
 static_assert(sizeof(CompactISDOpcodes) / sizeof(*CompactISDOpcodes) ==
               SelectionDAGISel::OPC_CheckOpcodeISD_BUILD_VECTOR -
-                      SelectionDAGISel::OPC_CheckOpcodeISD_SRL +
-                  1);
+                  SelectionDAGISel::OPC_CheckOpcodeISD_SRL + 1);
 
 LLVM_ATTRIBUTE_ALWAYS_INLINE static bool
 CheckCompactISDOpcode(unsigned MatcherOpcode, SDNode *N) {
diff --git a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
index 564fff8e2..1bc15e898 100644
--- a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
@@ -517,20 +517,16 @@ static unsigned emitMVT(MVT VT, raw_ostream &OS) {
 static StringRef getCompactISDOpcode(StringRef Opcode) {
   return StringSwitch<StringRef>(Opcode)
       .Case("ISD::SRL", "OPC_CheckOpcodeISD_SRL")
-      .Case("ISD::SIGN_EXTEND_INREG",
-            "OPC_CheckOpcodeISD_SIGN_EXTEND_INREG")
+      .Case("ISD::SIGN_EXTEND_INREG", "OPC_CheckOpcodeISD_SIGN_EXTEND_INREG")
       .Case("ISD::TargetConstant", "OPC_CheckOpcodeISD_TargetConstant")
       .Case("ISD::LOAD", "OPC_CheckOpcodeISD_LOAD")
       .Case("ISD::Constant", "OPC_CheckOpcodeISD_Constant")
-      .Case("ISD::INTRINSIC_WO_CHAIN",
-            "OPC_CheckOpcodeISD_INTRINSIC_WO_CHAIN")
+      .Case("ISD::INTRINSIC_WO_CHAIN", "OPC_CheckOpcodeISD_INTRINSIC_WO_CHAIN")
       .Case("ISD::SRA", "OPC_CheckOpcodeISD_SRA")
       .Case("ISD::ADD", "OPC_CheckOpcodeISD_ADD")
-      .Case("ISD::EXTRACT_SUBVECTOR",
-            "OPC_CheckOpcodeISD_EXTRACT_SUBVECTOR")
+      .Case("ISD::EXTRACT_SUBVECTOR", "OPC_CheckOpcodeISD_EXTRACT_SUBVECTOR")
       .Case("ISD::SPLAT_VECTOR", "OPC_CheckOpcodeISD_SPLAT_VECTOR")
-      .Case("ISD::EXTRACT_VECTOR_ELT",
-            "OPC_CheckOpcodeISD_EXTRACT_VECTOR_ELT")
+      .Case("ISD::EXTRACT_VECTOR_ELT", "OPC_CheckOpcodeISD_EXTRACT_VECTOR_ELT")
       .Case("ISD::XOR", "OPC_CheckOpcodeISD_XOR")
       .Case("ISD::MUL", "OPC_CheckOpcodeISD_MUL")
       .Case("ISD::AND", "OPC_CheckOpcodeISD_AND")

``````````

</details>


https://github.com/llvm/llvm-project/pull/202634


More information about the llvm-commits mailing list