Skip to content

Commit da3e58e

Browse files
committed
Revert "[RISCV][TTI] Scale the cost of the sext/zext with LMUL (#86617)"
This reverts commit 7545c63 as it's failing on the Linux bots.
1 parent 8a9c170 commit da3e58e

File tree

6 files changed

+556
-566
lines changed

6 files changed

+556
-566
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -909,33 +909,23 @@ InstructionCost RISCVTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
909909
if (!IsTypeLegal)
910910
return BaseT::getCastInstrCost(Opcode, Dst, Src, CCH, CostKind, I);
911911

912-
std::pair<InstructionCost, MVT> DstLT = getTypeLegalizationCost(Dst);
913-
914912
int ISD = TLI->InstructionOpcodeToISD(Opcode);
915913
assert(ISD && "Invalid opcode");
916914

915+
// FIXME: Need to consider vsetvli and lmul.
917916
int PowDiff = (int)Log2_32(Dst->getScalarSizeInBits()) -
918917
(int)Log2_32(Src->getScalarSizeInBits());
919918
switch (ISD) {
920919
case ISD::SIGN_EXTEND:
921-
case ISD::ZERO_EXTEND: {
922-
const unsigned SrcEltSize = Src->getScalarSizeInBits();
923-
if (SrcEltSize == 1) {
920+
case ISD::ZERO_EXTEND:
921+
if (Src->getScalarSizeInBits() == 1) {
924922
// We do not use vsext/vzext to extend from mask vector.
925923
// Instead we use the following instructions to extend from mask vector:
926924
// vmv.v.i v8, 0
927925
// vmerge.vim v8, v8, -1, v0
928-
return getRISCVInstructionCost({RISCV::VMV_V_I, RISCV::VMERGE_VIM},
929-
DstLT.second, CostKind);
926+
return 2;
930927
}
931-
if (PowDiff > 3)
932-
return BaseT::getCastInstrCost(Opcode, Dst, Src, CCH, CostKind, I);
933-
unsigned SExtOp[] = {RISCV::VSEXT_VF2, RISCV::VSEXT_VF4, RISCV::VSEXT_VF8};
934-
unsigned ZExtOp[] = {RISCV::VZEXT_VF2, RISCV::VZEXT_VF4, RISCV::VZEXT_VF8};
935-
unsigned Op =
936-
(ISD == ISD::SIGN_EXTEND) ? SExtOp[PowDiff - 1] : ZExtOp[PowDiff - 1];
937-
return getRISCVInstructionCost(Op, DstLT.second, CostKind);
938-
}
928+
return 1;
939929
case ISD::TRUNCATE:
940930
if (Dst->getScalarSizeInBits() == 1) {
941931
// We do not use several vncvt to truncate to mask vector. So we could

0 commit comments

Comments
 (0)