@@ -1191,9 +1191,6 @@ static const CostTblEntry VectorIntrinsicCostTable[]{
11911191 {Intrinsic::roundeven, MVT::f64 , 9 },
11921192 {Intrinsic::rint, MVT::f32 , 7 },
11931193 {Intrinsic::rint, MVT::f64 , 7 },
1194- {Intrinsic::lrint, MVT::i32 , 1 },
1195- {Intrinsic::lrint, MVT::i64 , 1 },
1196- {Intrinsic::llrint, MVT::i64 , 1 },
11971194 {Intrinsic::nearbyint, MVT::f32 , 9 },
11981195 {Intrinsic::nearbyint, MVT::f64 , 9 },
11991196 {Intrinsic::bswap, MVT::i16 , 3 },
@@ -1262,11 +1259,29 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
12621259 switch (ICA.getID ()) {
12631260 case Intrinsic::lrint:
12641261 case Intrinsic::llrint:
1265- // We can't currently lower half or bfloat vector lrint/llrint.
1266- if (auto *VecTy = dyn_cast<VectorType>(ICA.getArgTypes ()[0 ]);
1267- VecTy && VecTy->getElementType ()->is16bitFPTy ())
1268- return InstructionCost::getInvalid ();
1269- [[fallthrough]];
1262+ case Intrinsic::lround:
1263+ case Intrinsic::llround: {
1264+ auto LT = getTypeLegalizationCost (RetTy);
1265+ switch (ICA.getID ()) {
1266+ case Intrinsic::lrint:
1267+ case Intrinsic::llrint:
1268+ // We can't currently lower half or bfloat vector lrint/llrint.
1269+ if (auto *VecTy = dyn_cast<VectorType>(ICA.getArgTypes ()[0 ]);
1270+ VecTy && VecTy->getElementType ()->is16bitFPTy ())
1271+ return InstructionCost::getInvalid ();
1272+ break ;
1273+ case Intrinsic::lround:
1274+ case Intrinsic::llround:
1275+ // We can't currently lower scalable-vector lround/llround.
1276+ if (LT.second .isScalableVector ())
1277+ return InstructionCost::getInvalid ();
1278+ break ;
1279+ }
1280+ if (ST->hasVInstructions () && LT.second .isVector ())
1281+ return LT.first *
1282+ getRISCVInstructionCost (RISCV::VFCVT_X_F_V, LT.second , CostKind);
1283+ break ;
1284+ }
12701285 case Intrinsic::ceil:
12711286 case Intrinsic::floor:
12721287 case Intrinsic::trunc:
0 commit comments