[llvm] 32ee4f7 - [SDPatternMatch] Simplify EffectiveOperands and drop the template specialization. NFC (#226036)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 26 21:43:45 PDT 2026
Author: Craig Topper
Date: 2026-09-26T21:43:38-07:00
New Revision: 32ee4f7ed0ba2f169d22416c73360146153c9711
URL: https://github.com/llvm/llvm-project/commit/32ee4f7ed0ba2f169d22416c73360146153c9711
DIFF: https://github.com/llvm/llvm-project/commit/32ee4f7ed0ba2f169d22416c73360146153c9711.diff
LOG: [SDPatternMatch] Simplify EffectiveOperands and drop the template specialization. NFC (#226036)
The chain and glue operands are in fixed locations, we don't need a loop
to find them.
Use the template parameter to skip the constructor body instead of using
template specialization.
Added:
Modified:
llvm/include/llvm/CodeGen/SDPatternMatch.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/SDPatternMatch.h b/llvm/include/llvm/CodeGen/SDPatternMatch.h
index 2e82693708fca..80804a22ae4f0 100644
--- a/llvm/include/llvm/CodeGen/SDPatternMatch.h
+++ b/llvm/include/llvm/CodeGen/SDPatternMatch.h
@@ -404,29 +404,20 @@ template <bool ExcludeChain> struct EffectiveOperands {
unsigned Size = 0;
unsigned FirstIndex = 0;
- explicit EffectiveOperands(SDValue N) {
- const unsigned TotalNumOps = N->getNumOperands();
- FirstIndex = TotalNumOps;
- for (unsigned I = 0; I < TotalNumOps; ++I) {
- // Count the number of non-chain and non-glue nodes (we ignore chain
- // and glue by default) and retreive the operand index offset.
- EVT VT = N->getOperand(I).getValueType();
- if (VT != MVT::Glue && VT != MVT::Other) {
- ++Size;
- if (FirstIndex == TotalNumOps)
- FirstIndex = I;
+ explicit EffectiveOperands(SDValue N) : Size(N->getNumOperands()) {
+ if (ExcludeChain) {
+ // Glue if present, is the last operand.
+ if (Size != 0 && N->getOperand(Size - 1).getValueType() == MVT::Glue)
+ --Size;
+ // Chain if present, is the first operand.
+ if (Size != 0 && N->getOperand(0).getValueType() == MVT::Other) {
+ ++FirstIndex;
+ --Size;
}
}
}
};
-template <> struct EffectiveOperands<false> {
- unsigned Size = 0;
- unsigned FirstIndex = 0;
-
- explicit EffectiveOperands(SDValue N) : Size(N->getNumOperands()) {}
-};
-
// === Ternary operations ===
template <typename T0_P, typename T1_P, typename T2_P, bool Commutable = false,
bool ExcludeChain = false>
More information about the llvm-commits
mailing list