Skip to content

Commit

Permalink
[RISCV] Sink ordered reduction check into FAdd. NFC (#114180)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElvisWang123 authored Oct 31, 2024
1 parent f8d1ffd commit a8575c1
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1564,13 +1564,6 @@ RISCVTTIImpl::getArithmeticReductionCost(unsigned Opcode, VectorType *Ty,
}

// IR Reduction is composed by two vmv and one rvv reduction instruction.
if (TTI::requiresOrderedReduction(FMF)) {
Opcodes.push_back(RISCV::VFMV_S_F);
for (unsigned i = 0; i < LT.first.getValue(); i++)
Opcodes.push_back(RISCV::VFREDOSUM_VS);
Opcodes.push_back(RISCV::VFMV_F_S);
return getRISCVInstructionCost(Opcodes, LT.second, CostKind);
}
unsigned SplitOp;
switch (ISD) {
case ISD::ADD:
Expand All @@ -1590,6 +1583,13 @@ RISCVTTIImpl::getArithmeticReductionCost(unsigned Opcode, VectorType *Ty,
Opcodes = {RISCV::VMV_S_X, RISCV::VREDAND_VS, RISCV::VMV_X_S};
break;
case ISD::FADD:
if (TTI::requiresOrderedReduction(FMF)) {
Opcodes.push_back(RISCV::VFMV_S_F);
for (unsigned i = 0; i < LT.first.getValue(); i++)
Opcodes.push_back(RISCV::VFREDOSUM_VS);
Opcodes.push_back(RISCV::VFMV_F_S);
return getRISCVInstructionCost(Opcodes, LT.second, CostKind);
}
// We can't promote f16/bf16 fadd reductions.
if ((LT.second.getVectorElementType() == MVT::f16 &&
!ST->hasVInstructionsF16()) ||
Expand Down

0 comments on commit a8575c1

Please sign in to comment.