Skip to content

Commit d1acd1d

Browse files
committed
[CostModel] Address another review
1 parent 580b90d commit d1acd1d

File tree

2 files changed

+153
-151
lines changed

2 files changed

+153
-151
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,29 +1251,31 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
12511251
case Intrinsic::lround:
12521252
case Intrinsic::llround: {
12531253
auto LT = getTypeLegalizationCost(RetTy);
1254-
auto *SrcTy = ICA.getArgTypes().front();
1254+
Type *SrcTy = ICA.getArgTypes().front();
12551255
auto SrcLT = getTypeLegalizationCost(SrcTy);
12561256
if (ST->hasVInstructions() && LT.second.isVector()) {
12571257
ArrayRef<unsigned> Ops;
1258-
unsigned SrcEltSz =
1259-
DL.getTypeSizeInBits(cast<VectorType>(SrcTy)->getElementType());
1260-
unsigned DstEltSz =
1261-
DL.getTypeSizeInBits(cast<VectorType>(RetTy)->getElementType());
1258+
unsigned SrcEltSz = DL.getTypeSizeInBits(SrcTy->getScalarType());
1259+
unsigned DstEltSz = DL.getTypeSizeInBits(RetTy->getScalarType());
12621260
if (LT.second.getVectorElementType() == MVT::bf16) {
1261+
if (!ST->hasVInstructionsBF16Minimal())
1262+
return InstructionCost::getInvalid();
12631263
if (DstEltSz == 32)
12641264
Ops = {RISCV::VFWCVTBF16_F_F_V, RISCV::VFCVT_X_F_V};
12651265
else
12661266
Ops = {RISCV::VFWCVTBF16_F_F_V, RISCV::VFWCVT_X_F_V};
12671267
} else if (LT.second.getVectorElementType() == MVT::f16 &&
12681268
!ST->hasVInstructionsF16()) {
1269+
if (!ST->hasVInstructionsF16Minimal())
1270+
return InstructionCost::getInvalid();
12691271
if (DstEltSz == 32)
12701272
Ops = {RISCV::VFWCVT_F_F_V, RISCV::VFCVT_X_F_V};
12711273
else
12721274
Ops = {RISCV::VFWCVT_F_F_V, RISCV::VFWCVT_X_F_V};
12731275

1274-
} else if (SrcEltSz < DstEltSz) {
1275-
Ops = {RISCV::VFNCVT_X_F_W, RISCV::VMV_V_V};
12761276
} else if (SrcEltSz > DstEltSz) {
1277+
Ops = {RISCV::VFNCVT_X_F_W};
1278+
} else if (SrcEltSz < DstEltSz) {
12771279
Ops = {RISCV::VFWCVT_X_F_V};
12781280
} else {
12791281
Ops = {RISCV::VFCVT_X_F_V};

0 commit comments

Comments
 (0)