Skip to content

Commit b8a2c29

Browse files
committed
[RISCV] Cost ordered bf16/f16 w/ zvfhmin reductions as invalid
This moves the check earlier to fix this. This also uses BasicTTIImpl instead which now assigns a valid but expensive cost for fixed-length vectors, which reflects how codegen will actually scalarize them.
1 parent 31faa39 commit b8a2c29

File tree

2 files changed

+89
-72
lines changed

2 files changed

+89
-72
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,18 +1583,18 @@ RISCVTTIImpl::getArithmeticReductionCost(unsigned Opcode, VectorType *Ty,
15831583
Opcodes = {RISCV::VMV_S_X, RISCV::VREDAND_VS, RISCV::VMV_X_S};
15841584
break;
15851585
case ISD::FADD:
1586+
// We can't promote f16/bf16 fadd reductions.
1587+
if ((LT.second.getVectorElementType() == MVT::f16 &&
1588+
!ST->hasVInstructionsF16()) ||
1589+
LT.second.getVectorElementType() == MVT::bf16)
1590+
return BaseT::getArithmeticReductionCost(Opcode, Ty, FMF, CostKind);
15861591
if (TTI::requiresOrderedReduction(FMF)) {
15871592
Opcodes.push_back(RISCV::VFMV_S_F);
15881593
for (unsigned i = 0; i < LT.first.getValue(); i++)
15891594
Opcodes.push_back(RISCV::VFREDOSUM_VS);
15901595
Opcodes.push_back(RISCV::VFMV_F_S);
15911596
return getRISCVInstructionCost(Opcodes, LT.second, CostKind);
15921597
}
1593-
// We can't promote f16/bf16 fadd reductions.
1594-
if ((LT.second.getVectorElementType() == MVT::f16 &&
1595-
!ST->hasVInstructionsF16()) ||
1596-
LT.second.getVectorElementType() == MVT::bf16)
1597-
return InstructionCost::getInvalid();
15981598
SplitOp = RISCV::VFADD_VV;
15991599
Opcodes = {RISCV::VFMV_S_F, RISCV::VFREDUSUM_VS, RISCV::VFMV_F_S};
16001600
break;

0 commit comments

Comments
 (0)