[llvm] f2703c3 - [DAG] FoldConstantArithmetic - rename NumOps -> NumElts. NFC.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 5 06:32:55 PDT 2021


Author: Simon Pilgrim
Date: 2021-11-05T13:32:34Z
New Revision: f2703c3c3353031de8de8c465a59d31488b11fb3

URL: https://github.com/llvm/llvm-project/commit/f2703c3c3353031de8de8c465a59d31488b11fb3
DIFF: https://github.com/llvm/llvm-project/commit/f2703c3c3353031de8de8c465a59d31488b11fb3.diff

LOG: [DAG] FoldConstantArithmetic - rename NumOps -> NumElts. NFC.

NumOps represents the number of elements for vector constant folding, rename this NumElts so in future we can the consistently use NumOps to represent the number of operands of the opcode.

Minor cleanup before trying to begin generalizing FoldConstantArithmetic to support opcodes other than binops.

Added: 
    

Modified: 
    llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 05256464742c8..4a4d00e2b85c1 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -5256,7 +5256,7 @@ SDValue SelectionDAG::FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL,
   if (Opcode >= ISD::BUILTIN_OP_END || Opcode == ISD::CONCAT_VECTORS)
     return SDValue();
 
-  // For now, the array Ops should only contain two values.
+  // TODO: For now, the array Ops should only contain two values.
   // This enforcement will be removed once this function is merged with
   // FoldConstantVectorArithmetic
   if (Ops.size() != 2)
@@ -5329,18 +5329,18 @@ SDValue SelectionDAG::FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL,
   }
 
   SmallVector<SDValue, 4> Outputs;
-  unsigned NumOps = 0;
+  unsigned NumElts = 0;
   if (IsBVOrSV1)
-    NumOps = std::max(NumOps, N1->getNumOperands());
+    NumElts = std::max(NumElts, N1->getNumOperands());
   if (IsBVOrSV2)
-    NumOps = std::max(NumOps, N2->getNumOperands());
-  assert(NumOps != 0 && "Expected non-zero operands");
+    NumElts = std::max(NumElts, N2->getNumOperands());
+  assert(NumElts != 0 && "Expected non-zero operands");
   // Scalable vectors should only be SPLAT_VECTOR or UNDEF here. We only need
   // one iteration for that.
-  assert((!VT.isScalableVector() || NumOps == 1) &&
+  assert((!VT.isScalableVector() || NumElts == 1) &&
          "Scalable vector should only have one scalar");
 
-  for (unsigned I = 0; I != NumOps; ++I) {
+  for (unsigned I = 0; I != NumElts; ++I) {
     // We can have a fixed length SPLAT_VECTOR and a BUILD_VECTOR so we need
     // to use operand 0 of the SPLAT_VECTOR for each fixed element.
     SDValue V1;


        


More information about the llvm-commits mailing list