@@ -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