Skip to content

Commit

Permalink
[DAG] FoldConstantArithmetic - rename NumOps -> NumElts. NFC.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RKSimon committed Nov 5, 2021
1 parent a160aba commit f2703c3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f2703c3

Please sign in to comment.