Skip to content

Commit 44866b2

Browse files
committed
Revert "[RISCV] Refine cost on Min/Max reduction (llvm#79402)"
This reverts commit 2800448.
1 parent 730f498 commit 44866b2

File tree

5 files changed

+237
-266
lines changed

5 files changed

+237
-266
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -947,42 +947,13 @@ RISCVTTIImpl::getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty,
947947
}
948948

949949
// IR Reduction is composed by two vmv and one rvv reduction instruction.
950-
unsigned SplitOp;
951-
SmallVector<unsigned, 3> Opcodes;
952-
switch (IID) {
953-
default:
954-
llvm_unreachable("Unsupported intrinsic");
955-
case Intrinsic::smax:
956-
SplitOp = RISCV::VMAX_VV;
957-
Opcodes = {RISCV::VMV_S_X, RISCV::VREDMAX_VS, RISCV::VMV_X_S};
958-
break;
959-
case Intrinsic::smin:
960-
SplitOp = RISCV::VMIN_VV;
961-
Opcodes = {RISCV::VMV_S_X, RISCV::VREDMIN_VS, RISCV::VMV_X_S};
962-
break;
963-
case Intrinsic::umax:
964-
SplitOp = RISCV::VMAXU_VV;
965-
Opcodes = {RISCV::VMV_S_X, RISCV::VREDMAXU_VS, RISCV::VMV_X_S};
966-
break;
967-
case Intrinsic::umin:
968-
SplitOp = RISCV::VMINU_VV;
969-
Opcodes = {RISCV::VMV_S_X, RISCV::VREDMINU_VS, RISCV::VMV_X_S};
970-
break;
971-
case Intrinsic::maxnum:
972-
SplitOp = RISCV::VFMAX_VV;
973-
Opcodes = {RISCV::VFMV_S_F, RISCV::VFREDMAX_VS, RISCV::VFMV_F_S};
974-
break;
975-
case Intrinsic::minnum:
976-
SplitOp = RISCV::VFMIN_VV;
977-
Opcodes = {RISCV::VFMV_S_F, RISCV::VFREDMIN_VS, RISCV::VFMV_F_S};
978-
break;
979-
}
980-
// Add a cost for data larger than LMUL8
981-
InstructionCost SplitCost =
982-
(LT.first > 1) ? (LT.first - 1) *
983-
getRISCVInstructionCost(SplitOp, LT.second, CostKind)
984-
: 0;
985-
return SplitCost + getRISCVInstructionCost(Opcodes, LT.second, CostKind);
950+
InstructionCost BaseCost = 2;
951+
952+
if (CostKind == TTI::TCK_CodeSize)
953+
return (LT.first - 1) + BaseCost;
954+
955+
unsigned VL = getEstimatedVLFor(Ty);
956+
return (LT.first - 1) + BaseCost + Log2_32_Ceil(VL);
986957
}
987958

988959
InstructionCost

0 commit comments

Comments
 (0)