Skip to content

Commit 5f4adaf

Browse files
committed
fixup! Clarify the cost calculation logic
1 parent 493f56c commit 5f4adaf

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,18 +1547,18 @@ RISCVTTIImpl::getArithmeticReductionCost(unsigned Opcode, VectorType *Ty,
15471547
if (ISD == ISD::AND) {
15481548
// Example sequences:
15491549
// vmand.mm v8, v9, v8 ; needed every time type is split
1550-
// vmnot.m v8, v0
1550+
// vmnot.m v8, v0 ; alias for vmnand
15511551
// vcpop.m a0, v8
15521552
// seqz a0, a0
15531553

1554-
// Scalable VT: In nxv256i1 and larger vector elements,
1555-
// Fixed VT: If getFixedSizeInBits() >= (4 * getRealMinVLen()),
1556-
// the VMAND_MM instructions have started to be added.
1557-
InstructionCost NumOfVMAND = 0;
1558-
if (LT.second.isScalableVector() ||
1559-
LT.second.getFixedSizeInBits() == ST->getRealMinVLen())
1560-
NumOfVMAND = (LT.first > 2) ? (LT.first - 2) : 0;
1561-
return NumOfVMAND *
1554+
// See the discussion: https://github.com/llvm/llvm-project/pull/119160
1555+
// For LMUL <= 8, there is no splitting,
1556+
// the sequences are vmnot, vcpop and seqz.
1557+
// When LMUL > 8 and split = 1,
1558+
// the sequences are vmnand, vcpop and seqz.
1559+
// When LMUL > 8 and split > 1,
1560+
// the sequences are (LT.first-2) * vmand, vmnand, vcpop and seqz.
1561+
return ((LT.first > 2) ? (LT.first - 2) : 0) *
15621562
getRISCVInstructionCost(RISCV::VMAND_MM, LT.second, CostKind) +
15631563
getRISCVInstructionCost(RISCV::VMNAND_MM, LT.second, CostKind) +
15641564
getRISCVInstructionCost(RISCV::VCPOP_M, LT.second, CostKind) +

0 commit comments

Comments
 (0)